WO2012171434A1 - 文件或文件夹查找方法和装置 - Google Patents

文件或文件夹查找方法和装置 Download PDF

Info

Publication number
WO2012171434A1
WO2012171434A1 PCT/CN2012/076359 CN2012076359W WO2012171434A1 WO 2012171434 A1 WO2012171434 A1 WO 2012171434A1 CN 2012076359 W CN2012076359 W CN 2012076359W WO 2012171434 A1 WO2012171434 A1 WO 2012171434A1
Authority
WO
WIPO (PCT)
Prior art keywords
file
folder
record
read
address
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Ceased
Application number
PCT/CN2012/076359
Other languages
English (en)
French (fr)
Inventor
唐智
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Qihoo Technology Co Ltd
Original Assignee
Beijing Qihoo Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Qihoo Technology Co Ltd filed Critical Beijing Qihoo Technology Co Ltd
Publication of WO2012171434A1 publication Critical patent/WO2012171434A1/zh
Anticipated expiration legal-status Critical
Ceased legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/13File access structures, e.g. distributed indices

Definitions

  • the present invention relates to the field of computer storage data search technology, and in particular to a file or folder search method and apparatus. Background technique
  • a hard disk is the most commonly used storage device on a computer.
  • the files or folders on the computer are stored in the hard disk as a file record.
  • a hard disk can be divided into multiple partitions. Partitioning is essentially a format of a hard disk. When we create the partition, we have set the physical parameters of the hard disk, and specify the storage location of the hard disk master boot record (that is, the Master Boot Record, generally referred to as the master boot record area) and the boot record backup.
  • the technical problem to be solved by the present invention is to provide a file or folder searching method and apparatus, which can realize fast file or folder search and reduce occupation of computer resources.
  • the present invention discloses a file or folder search method, which comprises the following steps:
  • All file or folder attributes are read into memory according to the record address of the file or folder attribute
  • the obtaining a record address of all file or folder attributes in the hard disk according to the hard disk partition format; and reading all the file or folder attributes into the memory according to the record address of the file or folder attribute includes:
  • hard disk partition format is FAT12, FAT16 or FAT32, obtain the record address of all file or folder attributes from the file allocation table, and read all the file or folder attributes in the file allocation table according to the record address of the file or folder attribute. Memory; and/or
  • the hard disk partition format is NTFS
  • the record address of all file or folder attributes is obtained from the main file table, and all file or folder attributes in the main file table are read into the memory according to the record address of the file or folder attribute.
  • the obtaining a record address of all file or folder attributes from the file allocation table, and reading all the file or folder attributes in the file allocation table into the memory according to the record address of the file or folder attribute includes:
  • Reading the contents of the BIOS parameter block obtaining the starting address and size of the file allocation table; determining the start and end addresses of the records of all the files or folder attributes in the file allocation table;
  • All file or folder attributes in the file allocation table are read into memory based on the record start and end addresses of the records in which all file or folder attributes are determined.
  • the obtaining a record address of all file or folder attributes from the master file table, and reading all the file or folder attributes in the master file table into the memory according to the record address of the file or folder attribute includes:
  • Reading the contents of the BIOS parameter block obtaining the starting address and size of the main file table; determining the start and end addresses of the records of all the files or folder attributes in the main file table; All file or folder attributes in the main file table are read into memory based on the record start and end addresses of the records in which all file or folder attributes are determined.
  • the obtaining a record address of all file or folder attributes from the master file table, and reading all the file or folder attributes in the master file table into the memory according to the record address of the file or folder attribute includes:
  • the acquiring a hard disk partition format includes:
  • the contents of the master boot record area are read, and the hard disk partition format is obtained from the contents of the master boot record.
  • the traversing to find all or part of the files or folders in all file or folder attributes read into the memory comprises:
  • the traversing to find all or part of the files or folders in all file or folder attributes read into the memory comprises:
  • the traversing to find all or part of the files or folders in all file or folder attributes read into the memory comprises:
  • the search condition includes one or more of the following: a file name, a folder name, a creation date, a last access date, and a size.
  • the searching for the specified file or folder includes one or more of the following: a duplicate file or folder search, a 0 byte file or folder search, a specified file or a file Folder search, and junk file lookup.
  • the method further comprises deleting the found file or folder.
  • the method further includes:
  • all file or folder attributes in the hard disk include one or more of the following: name, size, creation time, creation date, last access date, last modified date.
  • the method further includes:
  • the reading all the file or folder attributes into the memory comprises:
  • the present invention also discloses a file or folder searching device, including:
  • the hard disk partition format obtaining module is configured to obtain a hard disk partition format
  • a record obtaining module configured to obtain a record address of all files or folder attributes in the hard disk according to the hard disk partition format; and read all file or folder attributes into the memory according to the record address of the file or folder attribute;
  • the lookup module configured to traverse all or part of a file or folder in all file or folder properties read into memory.
  • the record acquisition module includes:
  • the file allocation table record obtaining module is configured to obtain a record address of all file or folder attributes from the file allocation table when the hard disk partition format is FAT12, FAT16 or FAT32, and allocate the file according to the record address of the file or folder attribute. All file or folder properties in it are read into memory; and/or
  • the main file table record obtaining module is configured to obtain the record address and attribute of all file or folder attributes from the main file table when the hard disk partition format is NTFS, and the main file table according to the record address of the file or folder attribute All file or folder properties are read into memory.
  • the file allocation table record obtaining module includes:
  • a file allocation table start address and size obtaining module configured to read the content of the BIOS parameter block to obtain a starting address and a size of the file allocation table
  • a record address determining module configured to determine a record start and end address of a record item in which all files or folder attributes in the file allocation table are located;
  • the record content reading module is configured to read all file or folder attributes in the file allocation table into the memory according to the determined start and end addresses of the records of all the file or folder attributes determined.
  • the master file table record obtaining module includes:
  • the main file table start address and size obtaining module is configured to read the content of the BIOS parameter block, and obtain the starting address and size of the main file table;
  • a record address determining module configured to determine a record start and end address of a record item of all file or folder attributes of the master file table
  • the record content reading module is configured to read all file or folder attributes in the main file table into memory according to the determined start and end addresses of the records of all the file or folder attributes determined.
  • the master file table record obtaining module includes:
  • the metafile opening module is configured to open the metafile $MFT to obtain the record address of all file or folder attributes of the entire main file table, and obtain the file or folder attribute according to the record address of the file or folder attribute.
  • the hard disk partition format obtaining module includes:
  • the main boot recording area content reading module is configured to read the content of the main boot recording area, and obtain a hard disk partition format from the content of the main boot record.
  • the searching module includes:
  • the attribute information area determining module is configured to determine a storage location of the file or folder attribute in the main file table in the record item in which the storage file is located, and to search the storage location.
  • the device further includes:
  • the lookup condition addition module is configured to traverse all or all of the file or folder attributes read into memory based on the file or folder characteristics that were added at the time of the lookup as a search condition Part of a file or folder;
  • a presentation module that is configured to display the found files or folders.
  • the device further includes:
  • Processing module configured to delete the found files or folders.
  • the device further includes:
  • the file or folder attribute record address acquisition module is configured to obtain the record address of the file or folder attribute from the server in the new hard disk partition format.
  • the record acquisition module includes:
  • a read module that is configured to read all file or folder attributes into memory at a time; or a segment read module that is configured to read all file or folder attributes into memory.
  • the present invention also provides a computer readable recording medium on which a program for executing the above file or folder search method is recorded.
  • the present invention has the following advantages:
  • the file or folder searching method and apparatus of the present invention determines the record start address of the file or folder attribute recorded in the main boot record area of the hard disk, and determines each file or folder attribute record according to the hard disk partition type.
  • the offset of the record item so as to obtain the record start and end address of each file or folder attribute, and can read all file or folder attributes from the hard disk once or segmented according to the record start and end address of the file or folder attribute.
  • This method realizes file or folder search by one or several I/O operations, which can avoid the slow search speed caused by frequent I/O operations, improve the search speed and the response speed of the client, and avoid Client resources are unnecessarily occupied.
  • Embodiment 1 is a flow chart of Embodiment 1 of a file or folder searching method of the present invention
  • FIG. 2 is a flow chart showing an embodiment of a method for acquiring all files or folders according to a hard disk partition format shown in FIG. 1;
  • FIG. 3 is a schematic structural diagram of Embodiment 1 of a file or folder searching device of the present invention
  • 4 is a schematic structural diagram of Embodiment 1 of a record acquisition module of the present invention
  • Embodiment 2 is a schematic structural diagram of Embodiment 2 of a record acquisition module of the present invention.
  • Figure 6 is a block diagram showing the structure of the second embodiment of the file or folder searching device of the present invention. detailed description
  • the file or folder searching method and device of the present invention are applied to a computer client for searching for files or folders stored in a client's hard disk.
  • the file or folder searching method and apparatus of the present invention can be implemented by a computer program and installed in a client, and executed by the operation of the processor.
  • a first embodiment of the file or folder search method of the present invention which comprises the following steps:
  • Step 101 Obtain a hard disk partition format.
  • the hard disk partition format can be obtained by reading the contents of the main boot record area in real time; or after the user establishes the main partition, the extended partition and the logical drive letter according to the physical hard disk capacity and his own needs, and formats the hard disk, the partition of the hard disk
  • the format information is pre-stored in the address/address segment of the non-master boot record area in the hard disk or the memory, and the address/address segment is accessed by the specified interface function to obtain the hard disk partition format information.
  • the hard disk partition format can also be used to identify acquisitions by other third-party applications, and from the interface functions provided by third-party applications when needed. It can be understood that the hard disk partition format can also be obtained according to other methods, and the present invention is not limited thereto.
  • the reading the content of the main boot record area specifically includes the following steps:
  • the operating system can call the API CreateFile to open the corresponding hard disk device or partition. Thereby, the handle of the hard disk or the partition is obtained, and then the contents of the main boot record area (MBR, Master Boot Record) are read.
  • MRR Master Boot Record
  • the content of the main boot record area is read to determine the hard disk partition format, and the hard disk partition format identifier is recorded in the main boot record area, and the hard disk partition format can be determined by reading the contents of the main boot record area.
  • Windows partition format includes FAT12, FAT16, FAT32 And NTFS (New Technology File System).
  • FAT file allocation table
  • FAT32 File Allocation Table
  • MFT Master File Table
  • Step 102 Obtain a record address of all file or folder attributes in the hard disk according to the hard disk partition format, and read all file or folder attributes into the memory according to the record address of the file or folder attribute.
  • the file or folder attribute refers to the feature that can identify the file or folder, such as name, size, creation time, creation date, last access date, last modified date, and so on.
  • All file or folder attributes are recorded in the file allocation table or the main file table, where the carrier of the record corresponds to the hard disk partition format.
  • the partition format is FAT12
  • all file or folder attributes corresponding to FAT 16 or FAT32 are recorded in the file allocation table
  • the file or folder attribute corresponding to NTFS is recorded in the main file table.
  • partition format of the hard disk is one of FAT12, FAT 16 or FAT32, then the contents of the file allocation table are read. If the partition format of the hard disk is NTFS, then the contents of the main file table are read.
  • Reading all file or folder attributes into memory can be read into memory at a time, or can be read into memory in segments, that is, read in several times.
  • the specific value can be determined according to the capacity and occupancy of the memory. For example, when the memory is large enough, you can choose to read all file or folder attributes into memory at a time. When there is not enough memory, you can read all file or folder attributes into memory several times, thus avoiding frequent input/ Output operations and excessive system resources.
  • D1 read the contents of the BPB (BIOS Parameter Block), and obtain the starting address and size of the file allocation table.
  • BPB basic Parameter Block
  • the BPB record is recorded in the main boot record area, and the BPB records the start address of the file allocation table according to a fixed format.
  • the content of the BPB can be read from the main boot record area, and the BPB corresponding can be found by analyzing the BPB content.
  • the record byte you can get the starting address of the file allocation table.
  • BPB defines the number of bytes per sector, several sectors per cluster, and the total number of sectors.
  • the size of each cluster the number of bytes per sector * the number of sectors per cluster can be calculated from these files or folders.
  • the BPB records the starting cluster number and the number of clusters occupied by the file allocation table, so that the size of the file allocation table can be obtained.
  • D2 determines the record start address of the record item where all file or folder attributes in the file allocation table are located.
  • the offset between each record item in the file allocation table is fixed, and the storage location of the file or folder attribute in each record item is also certain, after determining the start address of the file allocation table.
  • the termination address of the file allocation table can be determined by the starting address, offset, and size of the file allocation table. Specifically, the termination address of the file allocation table can be calculated by the starting address and size, and obtained by the offset.
  • the entire file allocation table can be read into the memory once or in sections, including all file or folder attributes, that is, once or Several I/O operations.
  • One way of reading the contents of the main file table is the same as the foregoing method of reading the contents of the file allocation table, that is, the starting address and size of the main file table are obtained by BPB, and then determined according to the offset of the main file table.
  • the start and end addresses of the records of all the files or folder attributes in the main file table, and all file or folder attributes of the entire main file table are read into the memory once or in sections.
  • reading the contents of the main file table can also directly open the meta file $ ⁇ « ⁇ through the CreateFile function to obtain the record address of all the files or folder attributes of the entire main file table, and according to the file. Or the record address of the record entry where the folder attribute is located to get the file or folder properties, and then read all file or folder properties into memory one or the other.
  • the storage location of the file or folder on the hard disk can also be obtained, so that in step 103, all or part of the file or folder is traversed in all file or folder attributes read into the memory.
  • a record item in the file allocation table or the main file table corresponds to a file or folder, and all the files and folders on the entire partition are listed by traversing the file or folder attribute in all the records, thereby realizing quick search. All or part of a file or folder.
  • each record occupies 32 bytes, where the first 10 bytes are the file name (Dos file name rule, ie, the short file name), and then there is 1 byte to record the file attribute.
  • One byte is reserved, then the creation time, the creation date, the last access period, the total number of clusters occupied, the last modified date, the address of the first cluster, and the file size. Because each data occupies fewer bytes, it directly acquires relevant information by traversing the entire data. Specifically, starting from the record start address of the first data, each time the offset data occupies the number of bytes, that is, 32 bytes, it is possible to traverse all the file or folder information to obtain the attributes of the file or folder. information.
  • each record occupies 1024 bytes, and the file or folder attribute occupies the first 512 bytes. After determining the record start address of the record where the file or folder is located, read 512 later. Bytes, you can get the attribute information of the file or folder. Therefore, when searching, it is also possible to first determine the storage location of the file or folder attribute, and then read the relevant attribute in the found storage location, without traversing the entire record item, thereby saving the search time. Specifically, in the main file table, all attribute information of each file or folder is recorded in the 512 bytes of the area beginning with the first "FILE0" of the record entry, by finding the first "FILE0" The beginning area, then read 512 bytes later Get the attribute information.
  • the file allocation table or the main file table records the details of the file or folder
  • the search condition may include a file name, a creation date, a last access date, a size, and the like.
  • the file or folder lookup method of the present invention can be applied to file lookups of various scenes by adding search conditions, such as duplicate file or folder lookup, 0 byte file or folder lookup, specified file or folder lookup, and garbage File lookups and more.
  • found files or folders can also be deleted as needed. For example, delete duplicate files or folders, junk files, 0-byte files or folders, and more.
  • the record address of the file or folder attribute in the partition format can be obtained from the server, thereby reading the file or folder attribute into the memory according to the record address of the file or folder attribute.
  • the Windows operating system is taken as an example to describe the foregoing file or folder search method. Assuming that the partition of the hard disk is in the NTFS format and the file search is performed on the C disk, the specific process is as follows:
  • the start address of the MFT can be read from the BPB, specifically the first in the BPB 49 - 57 bytes.
  • the first two bytes in BPB define the number of bytes per sector.
  • the next two bytes define how many sectors per cluster.
  • the 41st to 49th bytes are the total number of sectors. Sector.
  • the specific method is: find the first area starting with "FILE0", read 512 bytes later, all the attributes related to this file or folder are in the 512 bytes, including the file name, whether the directory, File size, The starting cluster number occupied by the file, how many clusters it occupies, the date of creation, the date of access, and so on.
  • the first 512 bytes are read instead of 1024 bytes, because the next 512 nodes are data segments.
  • Some files smaller than 512 bytes will be directly stored in the MFT.
  • the search file the first 512 bytes are read. You can achieve the lookup. Then offset 1024 bytes to read the next file content, and so on, until all the file information is read, you can complete the search.
  • FIG. 3 an embodiment of a file or folder search apparatus of the present invention is shown, which includes: a hard disk partition format acquisition module 12, a record acquisition module 20, and a lookup module 30.
  • the hard disk partition format obtaining module 12 is configured to obtain a hard disk partition format.
  • the hard disk partition format is usually FAT12, FAT16, FAT32 and NTFS.
  • the hard disk partition format acquisition module 12 includes a master boot record area content read module 10 configured to read the contents of the master boot record area and obtain a hard disk partition format from the contents of the master boot record.
  • the hard disk partition format can also be used to pre-store the partition format information of the hard disk in the hard disk or the non-master boot in the memory after the user establishes the primary partition, the extended partition, and the logical drive letter according to the physical hard disk capacity and the needs of the user.
  • the address/address segment of the recording area is accessed by the specified interface function to obtain the hard disk partition format information.
  • the hard disk partition format can also be used by other third-party applications to identify the acquisition and obtain it from the interface functions provided by the third-party application when needed. It can be understood that the hard disk partition format can also be obtained according to other methods, which is not limited by the present invention.
  • the record acquisition module 20 is configured to obtain a record address of all file or folder attributes according to the hard disk partition format, and read all file or folder attributes into the memory according to the record address of the file or folder attribute.
  • the record obtaining module 20 is a file allocation table record obtaining module configured to obtain a record address of all file or folder attributes from the file allocation table.
  • the record acquisition module 20 is a master file table record acquisition module configured to obtain a record address of all file or folder attributes from the master file table.
  • the lookup module 30 is configured to traverse through all of the file or folder properties read into memory to find all or part of the file or folder.
  • the file allocation table record acquisition module includes a file allocation table start address and size acquisition module 211, a record address determination module 213, and a record content reading module 215.
  • the file allocation table start address and size obtaining module 211 is configured to read the content of the BPB, and obtain the starting address and size of the file allocation table.
  • the record address determining module 213 is configured to determine a record start and end address of all files or folders in the file allocation table.
  • the record content reading module 215 is configured to read all file or folder attributes in the file allocation table into the memory according to the determined start and end addresses of the records of all the file or folder attributes determined.
  • the master file table record obtaining module includes a master file table start address and size obtaining module 231, a record address determining module 233, and a record content reading module 235.
  • the main file table start address and size obtaining module 231 is configured to read the content of the BPB, and obtain the starting address and size of the main file table.
  • a record address determination module 233 is configured to determine a record start and end address of all files or folders of the master file table.
  • the record content reading module 235 is configured to read all file or folder attributes in the main file table into the memory according to the determined start and end addresses of the records of all the files or folder attributes determined.
  • the master file table record obtaining module may further include a meta file open module 237 configured to open the meta file $MFT to obtain a record address of all file or folder attributes of the entire master file table, and according to the file or folder attribute.
  • the record address gets the file or folder attribute. Specifically, you can open the meta file $ ⁇ « ⁇ through the CreateFile function.
  • Fig. 6 is a view showing the configuration of a second embodiment of the file or folder search device of the present invention.
  • the lookup module 30 includes a file or folder attribute traversal module 31 and/or a property information area determining module 33.
  • the file or folder property traversal module is configured to traverse each file or folder property to obtain file or folder properties.
  • the attribute information area determining module is configured to determine a storage location of a file or folder attribute in the main file table to search for the storage location.
  • the file or folder searching device further includes a search condition adding module 50 and a display module 70.
  • the lookup condition adding module 50 is configured as a search condition for the file or folder feature added at the time of the lookup. For example, file name, creation date, last access date, size, etc. Find conditions.
  • a presentation module that is configured to display the found files or folders.
  • the file or folder lookup device further includes a processing module 80 configured to delete the found file or folder.
  • the file or folder search device further includes a file or folder attribute record address obtaining module 90 configured to obtain a record address of the file or folder attribute from the server in the presence of a new hard disk partition format.
  • the record acquisition module 20 further includes a read module 25 configured to read all files or folders into the memory at a time; or a segment read module 27 configured to segment all file or folder attributes. Read in memory.
  • the present invention also provides a computer readable recording medium on which a program for executing the above file or folder searching method is recorded.
  • a program for executing the above file or folder searching method is recorded.
  • the computer readable recording medium includes any mechanism for storing or transmitting information in a form readable by a computer (e.g., a computer).
  • a machine-readable medium includes a read only memory (ROM), a random access memory (RAM), a magnetic disk storage medium, an optical storage medium, a flash storage medium, an electrical, optical, acoustic, or other form of propagated signal (eg, a carrier wave) , infrared signals, digital signals, etc.).
  • the file or folder searching method and apparatus of the present invention determines the address of each file or folder record by reading the starting address and size of the file or folder record recorded in the main boot recording area, thereby all files or The folder is recorded once or segmented into memory, and then all file or folder records are traversed in memory to find the file.
  • This method realizes file search by one or several I/O operations, which can avoid the slow search speed caused by frequent I/O operations, improve the search speed and the response speed of the client, and avoid the client resources. Make unnecessary occupations.
  • the description is different from the other embodiments, and the same similar parts between the respective embodiments can be referred to each other. For the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the description of the method embodiment.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Data Mining & Analysis (AREA)
  • Databases & Information Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

一种文件或文件夹查找方法,包括以下步骤:获取硬盘分区格式;根据硬盘分区格式获取硬盘中所有文件或文件夹属性的记录地址,并根据所述文件或文件夹属性的记录地址将所有文件或文件夹属性读入内存;在读入内存的所有文件或文件夹属性中遍历查找全部或部分文件或文件夹。本发明还提供了一种实现前述方法的文件或文件夹查找装置。本发明的文件或文件夹查找方法和装置,能够实现快速的文件或文件夹的查找和减少对计算机资源的占用。

Description

文件或文件夹查找方法和装置
技术领域
本发明涉及计算机存储数据查找技术领域,特别是涉及一种文件或文 件夹查找方法和装置。 背景技术
硬盘是现在计算机上最常用的存储设备, 计算机中文件或文件夹都 以文件记录的形式存储在硬盘里。 一个硬盘可以区分为多个分区。 分区 从实质上说就是对硬盘的一种格式化。 当我们创建分区时, 就已经设置 好了硬盘的各项物理参数, 指定了硬盘主引导记录 (即 Master Boot Record, 一般简称为主引导记录区) 和引导记录备份的存放位置。
通常 Windows下从硬盘中查找一个指定的或者全部的文件或文件夹 是调用 FindFirstFile和 FindNextFile这两个 API ( Application Programming Interface , 应用程序编程接口) 来实现的。 实际运用中, 因为硬盘中的文 件或文件夹数量较大, 例如, 十万或者更多, 调用这两个 API会发生数 以万次的 I/O ( Input/Output, 输入 /输出 )操作, 因此查找速度上会较慢。
在 Windows XP操作系统之后加入了索引技术,对于重复操作能实现 快速的查找, 但是在第一次搜索时也还是比较慢的。 另外, 因为频繁的 使用 I/O操作, 还可能造成对计算机资源的占用, 从而使计算机的响应变 得緩慢。 发明内容
本发明所要解决的技术问题是提供一种文件或文件夹查找方法和装 置, 能够实现快速的文件或文件夹的查找和减少对计算机资源的占用。
为了解决上述问题, 本发明公开了一种文件或文件夹查找方法, 包 括以下步骤:
获取硬盘分区格式;
根据硬盘分区格式获取硬盘中所有文件或文件夹属性的记录地址; 并
根据所述文件或文件夹属性的记录地址将所有文件或文件夹属性读 入内存;
在读入内存的所有文件或文件夹属性中遍历查找全部或部分文件或 文件夹。
优选地, 所述根据硬盘分区格式获取硬盘中所有文件或文件夹属性 的记录地址; 并根据所述文件或文件夹属性的记录地址将所有文件或文 件夹属性读入内存包括:
若硬盘分区格式为 FAT12, FAT16或 FAT32, 从文件分配表获取所有 文件或文件夹属性的记录地址, 并根据文件或文件夹属性的记录地址将 文件分配表中的所有文件或文件夹属性读入内存; 和 /或
若硬盘分区格式为 NTFS ,从主文件表中获取所有文件或文件夹属性 的记录地址, 并根据文件或文件夹属性的记录地址将主文件表中的所有 文件或文件夹属性读入内存。
优选地, 所述从文件分配表获取所有文件或文件夹属性的记录地址, 并根据文件或文件夹属性的记录地址将文件分配表中的所有文件或文件 夹属性读入内存包括:
读取 BIOS参数块的内容, 获取文件分配表的起始地址和大小; 确定文件分配表中所有文件或文件夹属性所在记录项的记录起止地 址;
根据确定的所有文件或文件夹属性所在记录项的记录起止地址将文 件分配表中所有文件或文件夹属性读入内存。
优选地, 所述从主文件表中获取所有文件或文件夹属性的记录地址, 并根据文件或文件夹属性的记录地址将主文件表中的所有文件或文件夹 属性读入内存包括:
读取 BIOS参数块的内容, 获取主文件表的起始地址和大小; 确定主文件表中所有文件或文件夹属性所在记录项的记录起止地 址; 根据确定的所有文件或文件夹属性所在记录项的记录起止地址将主 文件表中所有文件或文件夹属性读入内存。
优选地, 所述从主文件表中获取所有文件或文件夹属性的记录地址, 并根据文件或文件夹属性的记录地址将主文件表中的所有文件或文件夹 属性读入内存包括:
打开元文件 $MFT 来获取整个主文件表的所有文件或文件夹属性所 在记录项的记录地址, 并根据所述文件或文件夹属性所在记录项的记录 地址获取所述文件或文件夹属性。
优选地, 所述获取硬盘分区格式包括:
读取主引导记录区的内容, 从所述主引导记录的内容中获取硬盘分 区格式。
优选地, 所述在读入内存的所有文件或文件夹属性中遍历查找全部 或部分文件或文件夹包括:
确定文件分配表或主文件表的起始地址;
从起始地址开始, 依次偏移文件或文件夹属性所在记录项所占用的 字节数, 直至遍历完成。
优选地, 所述在读入内存的所有文件或文件夹属性中遍历查找全部 或部分文件或文件夹包括:
确定主文件表中文件或文件夹属性在其所在记录项中的存储位置, 在所述存储位置进行查找。
优选地, 所述在读入内存的所有文件或文件夹属性中遍历查找全部 或部分文件或文件夹包括:
根据在查找时加入的文件或文件夹特征作为查找条件, 在读入内存 的所有文件或文件夹属性中遍历查找全部或部分文件或文件夹。
优选地, 所述查找条件包括以下一种或多种: 文件名、 文件夹名、 创建日期、 最后访问日期和大小。
优选地, 所述指定文件或文件夹的查找包括以下一种或几种: 重复文件或文件夹查找、 0字节文件或文件夹查找、 指定文件或文件 夹查找, 以及垃圾文件查找。
优选地, 所述方法还包括删除所述查找到的文件或文件夹。
优选地, 所述方法还包括:
若出现新的硬盘分区格式, 从服务器中获取文件或文件夹属性的记 录地址。
优选地, 所述硬盘中所有文件或文件夹属性包括以下一种或多种: 名称、 大小、 创建时间、 创建日期、 最后访问日期、 最后修改日期。 优选地, 所述方法还包括:
根据硬盘分区格式获取硬盘中所有文件或文件夹的存放位置。
优选地, 所述将所有文件或文件夹属性读入内存包括:
将所有文件或文件夹属性一次读入内存; 或
将所有文件或文件夹属性分段读入内存。
为了解决上述问题, 本发明还公开了一种文件或文件夹查找装置, 包括:
硬盘分区格式获取模块, 配置为获取硬盘分区格式;
记录获取模块, 配置为根据硬盘分区格式获取硬盘中所有文件或文 件夹属性的记录地址; 并根据所述文件或文件夹属性的记录地址将所有 文件或文件夹属性读入内存;
查找模块, 配置为在读入内存的所有文件或文件夹属性中遍历查找 全部或部分文件或文件夹。
优选地, 所述记录获取模块包括:
文件分配表记录获取模块, 配置为当硬盘分区格式为 FAT12, FAT16 或 FAT32时, 从文件分配表获取所有文件或文件夹属性的记录地址, 并 根据文件或文件夹属性的记录地址将文件分配表中的所有文件或文件夹 属性读入内存; 和 /或
主文件表记录获取模块, 配置为当硬盘分区格式为 NTFS时,从主文 件表中获取所有文件或文件夹属性的记录地址和属性, 并根据文件或文 件夹属性的记录地址将主文件表中的所有文件或文件夹属性读入内存。 优选地, 所述文件分配表记录获取模块包括:
文件分配表起始地址和大小获取模块,配置为读取 BIOS参数块的内 容, 获取文件分配表的起始地址和大小;
记录地址确定模块, 配置为确定文件分配表中所有文件或文件夹属 性所在记录项的记录起止地址;
记录内容读取模块, 配置为根据确定的所有文件或文件夹属性所在 记录项的记录起止地址将文件分配表中所有文件或文件夹属性读入内 存。
优选地, 所述主文件表记录获取模块包括:
主文件表起始地址和大小获取模块, 配置为读取 BIOS 参数块的内 容, 获取主文件表的起始地址和大小;
记录地址确定模块, 配置为确定主文件表所有文件或文件夹属性所 在记录项的记录起止地址;
记录内容读取模块, 配置为根据确定的所有文件或文件夹属性所在 记录项的记录起止地址将主文件表中所有文件或文件夹属性读入内存。
优选地, 所述主文件表记录获取模块包括:
元文件打开模块,配置为打开元文件 $MFT来获取整个主文件表的所 有文件或文件夹属性的记录地址, 并根据所述文件或文件夹属性的记录 地址获取所述文件或文件夹属性。
优选地, 所述硬盘分区格式获取模块包括:
主引导记录区内容读取模块, 配置为读取主引导记录区的内容, 从 所述主引导记录的内容中获取硬盘分区格式。
优选地, 所述查找模块包括:
属性信息区域确定模块, 配置为确定主文件表中文件或文件夹属性 在其所在记录项中的存储位置, 对所述存储位置进行查找。
优选地, 所述装置还包括:
查找条件添加模块, 配置为根据在查找时加入的文件或文件夹特征 作为查找条件, 在读入内存的所有文件或文件夹属性中遍历查找全部或 部分文件或文件夹; 和
展示模块, 配置为展示查找到的文件或文件夹。
优选地, 所述装置还包括:
处理模块, 配置为删除查找到的文件或文件夹。
优选地, 所述装置还包括:
文件或文件夹属性记录地址获取模块, 配置为在出现新的硬盘分区 格式, 从服务器中获取文件或文件夹属性的记录地址。
优选地, 所述记录获取模块包括:
一次读取模块, 配置为将所有文件或文件夹属性一次读入内存; 或 分段读取模块, 配置为将所有文件或文件夹属性分段读入内存。 本发明还提供了一种在其上记录有用于执行上述文件或文件夹查找 方法的程序的计算机可读记录介质。
与现有技术相比, 本发明具有以下优点:
本发明的文件或文件夹查找方法和装置通过读取硬盘的主引导记录 区中所记载的文件或文件夹属性的记录起始地址, 并根据硬盘分区类型 来确定每个文件或文件夹属性记录所在记录项的偏移量, 从而获取每个 文件或文件夹属性的记录起止地址, 并可以根据文件或文件夹属性的记 录起止地址将所有文件或文件夹属性从硬盘一次或分段读入到内存中, 然后在内存中遍历所有的文件或文件夹属性来对文件或文件夹进行查 找。 此种方式通过一次或几次 I/O操作来实现文件或文件夹查找, 可以避 免因为频繁进行 I/O操作而造成的查找速度较慢的情况,提高查找速度以 及客户端的响应速度, 避免对客户端资源进行不必要的占用。 附图说明
图 1是本发明的文件或文件夹查找方法实施例一的流程图;
图 2是图 1所示的根据硬盘分区格式获取所有文件或文件夹记录方法 实施例的流程图;
图 3是本发明的文件或文件夹查找装置实施例一的结构示意图; 图 4是本发明的记录获取模块实施例一的结构示意图;
图 5是本发明的记录获取模块实施例二的结构示意图;
图 6是本发明的文件或文件夹查找装置实施例二的结构示意图。 具体实施方式
为使本发明实施例的上述目的、 特征和优点能够更加明显易懂, 下面结 合附图和具体实施方式对本发明作进一步详细的说明。
本发明的文件或文件夹查找方法及装置应用于计算机客户端, 用于对 客户端的硬盘中存储的文件或文件夹进行查找。 具体的, 本发明的文件或 文件夹查找方法及装置可以通过计算机程序实现, 并安装于客户端中, 通 过处理器的运行来执行。
参照图 1 , 示出本发明的文件或文件夹查找方法的实施例一, 包括以 下步骤:
步骤 101 , 获取硬盘分区格式。
硬盘分区格式可以通过实时读取主引导记录区的内容来获取; 或者 在用户根据物理硬盘容量和自己的需要, 建立主分区、 扩展分区和逻辑 盘符并格式化处硬盘后, 将硬盘的分区格式信息预先存储在硬盘或者内 存中的非主引导记录区的地址 /地址段处, 并以供指定接口函数访问该地 址 /地址段, 来获取硬盘分区格式信息。 硬盘分区格式还可以釆用其他第 三方应用软件来识别获取, 当需要时从第三方应用软件提供的接口函数 获取。 可以理解的是, 硬盘分区格式还可以根据其他方式来获取, 本发 明对此并不限制。
其中, 读取主引导记录区的内容具体包括以下步骤: 操作系统可以 调用 API CreateFile来打开相应的硬盘设备或分区。 从而得到硬盘或分区 的句柄, 进而读取到主引导记录区 (MBR, Master Boot Record )的内容。
读取主引导记录区的内容判断硬盘分区格式, 在主引导记录区中记 载有硬盘分区格式的标识, 通过读取主引导记录区的内容便可以确定硬 盘分区格式。 目前 Windows 的分区格式包括有 FAT12, FAT16, FAT32 和 NTFS ( New Technology File System )。 其中对于前 3种分区, 硬盘上 的所有文件、文件夹信息都记录于文件分配表( FAT, File Allocation Table ) 里。 对于 NTFS 分区, 所有文件、 文件夹信息存储在主文件表(MFT, Master File Table ) 里。
步骤 102,根据硬盘分区格式获取硬盘中所有文件或文件夹属性的记 录地址, 并根据所述文件或文件夹属性的记录地址将所有文件或文件夹 属性读入内存。
其中, 文件或文件夹属性是指名称、 大小、 创建时间、 创建日期、 最后访问日期、 最后修改日期等等能对文件或文件夹进行识别的特征。
所有文件或文件夹属性记录在文件分配表或主文件表中, 其中, 其 记录的载体与硬盘分区格式对应。 分区格式为 FAT12, FAT 16 或 FAT32 对应的所有文件或文件夹属性记录在文件分配表中, 分区格式为 NTFS 对应的文件或文件夹属性记录在主文件表中。
如果硬盘的分区格式为 FAT12, FAT 16或 FAT32的其中一种, 那么 读取文件分配表的内容。 如果硬盘的分区格式为 NTFS, 那么则读取主文 件表的内容。
将所有文件或文件夹属性读入内存可以是一次读入内存, 也可以是 分段读入内存, 即分几次读入, 具体的可以根据内存的容量和占用情况 来确定。 例如, 当内存足够大的时候, 可以选择将所有文件或文件夹属 性一次读入内存, 当内存不足时, 则可以分几次将所有文件或文件夹属 性读入内存, 从而避免频繁的输入 /输出操作以及占用过多的系统资源。
参照图 2, 其中, 读取文件分配表的内容的具体过程为:
D1 , 读取 BPB(BIOS参数块, BIOS Parameter Block)的内容, 获取文 件分配表的起始地址和大小。
其中, BPB记录在主引导记录区中, BPB会按照固定的格式来记录 文件分配表的起始地址, 从主引导记录区可以读取到 BPB的内容, 通过 对 BPB内容的分析可以找到 BPB对应的记录字节,便可以获取文件分配 表的起始地址。 另外, BPB 中定义了每扇区字节数、 每个簇有几个扇区以及总扇区 数。 通过这些文件或文件夹可以计算出每簇的大小 =每扇区字节数 *每个 簇的扇区数。 BPB 中记载了文件分配表所占用的起始簇号及簇的占用数 量, 从而可以获取文件分配表的大小。
D2 , 确定文件分配表中所有文件或文件夹属性所在记录项的记录起 止地址。
一般来说, 文件分配表中每一个记录项之间的偏移量是一定的, 文 件或文件夹属性在每一个记录项中的存储位置也是一定的, 在确定文件 分配表的起始地址后, 可以通过偏移量来获取到每个文件或文件夹属性 所在记录项的起止地址, 从而确定每个文件或文件夹属性的记录地址。 例如, 文件分配表中的一个记录项的偏移量为 1024个字节, 文件或文件 夹属性占用前 512 个字节, 那么在确定文件分配表中每个记录项的起止 地址后, 便可以确定文件或文件夹属性的记录地址。
通过文件分配表的起始地址、 偏移量和大小可以确定文件分配表的 终止地址, 具体的, 通过起始地址和大小, 可以计算出文件分配表的终 止地址, 在通过偏移量来获取起始地址和终止地址之间的所有文件或文 件夹属性所在记录项的记录起止地址, 从而可以保证文件分配表的所有 文件或文件夹属性所在记录项的记录起止地址都能被确定。
D3 , 根据确定的所有文件或文件夹属性所在记录项的记录起止地址 将文件分配表中所有文件或文件夹属性读入内存。
在确定文件分配表中所有文件或文件夹属性所在记录项的记录起止 地址之后, 便可以将整个文件分配表一次性或分段读入内存, 包括所有 文件或文件夹属性, 也即进行一次或几次 I/O操作。
读取主文件表的内容的其中一种方式与前述的读取文件分配表的内 容的方式相同, 即通过 BPB获取主文件表的起始地址和大小, 然后根据 主文件表的偏移量确定主文件表中所有文件或文件夹属性所在记录项的 记录起止地址, 将整个主文件表所有文件或文件夹属性一次或分段读入 内存。 因为 NTFS 分区的特殊性, 读取主文件表的内容还可以直接通过 CreateFile函数打开元文件$^«^来获取整个主文件表的所有文件或文件 夹属性所在记录项的记录地址, 并根据文件或文件夹属性所在记录项的 记录地址来获取文件或文件夹属性, 然后将所有文件或文件夹属性一次 或分段读入内存中。
进一步地, 还可以获取文件或文件夹在硬盘中的存放位置, 从而便 步骤 103 ,在读入内存的所有文件或文件夹属性中遍历查找全部或部 分文件或文件夹。
其中, 文件分配表或主文件表里一个记录项对应一个文件或文件夹, 通过遍历所有记录项中的文件或文件夹属性将整个分区上的所有文件及 文件夹列出, 从而可以实现快速查找全部或部分文件或文件夹。
对于文件分配表来说, 每个记录项占用 32个字节, 其中, 前 10个 字节是文件名 (Dos文件名规则, 即短文件名), 接下来有 1个字节记录 文件属性, 1个字节是保留的, 然后依次是创建时间, 创建日期, 最后访 问曰期, 总共占用了几个簇, 最后修改日期, 第一个簇的地址, 文件大 小。 因为每个数据所占用的字节数较少, 因此直接通过遍历整个数据来 获取相关的信息。 具体的, 从第一个数据的记录起始地址开始, 每次偏 移数据占用的字节数, 即 32个字节, 就能遍历所有文件或文件夹信息, 以获取文件或文件夹的属性信息。
对于主文件表来说, 每个记录项占用 1024个字节, 文件或文件夹属 性占用前 512 个字节, 在确定文件或文件夹所在记录项的记录起始地址 后, 往后读取 512 个字节, 便可以获取到文件或文件夹的属性信息。 因 此, 在查找时, 还可以先确定文件或文件夹属性的存储位置, 然后再在 查找到的存储位置来读取相关属性, 无需遍历整个记录项, 从而可以节 省查找时间。 具体的, 主文件表中, 每个文件或文件夹所有属性信息都 记录在该其所在记录项第一个 "FILE0" 开头的区域往后 512个字节中, 通过找到第一个 "FILE0" 开头的区域, 然后往后读取 512个字节也可以 获取到属性信息。
另外, 因为文件分配表或主文件表记录了文件或文件夹的详细信息, 因此在查找时, 可以加入文件或文件夹特征作为查找条件, 在读入内存 的所有文件或文件夹属性中遍历查找全部或部分文件或文件夹, 从而提 高查找速度。 另外, 还可以根据需要展示查找到的文件或文件夹。 其中, 查找条件可以包括文件名, 创建日期, 最后访问日期, 大小等等。 通过 添加查找条件可以使本发明的文件或文件夹查找方法应用于多种场景的 文件查找, 如重复文件或文件夹查找、 0字节文件或文件夹查找、 指定文件 或文件夹查找, 以及垃圾文件查找等等。
进一步地, 还可以根据需要删除查找到的文件或文件夹。 例如删除 重复文件或文件夹、 垃圾文件、 0字节文件或文件夹等等。
进一步地, 当出现新的硬盘分区格式时, 可以从服务器中获取该分区格 式下文件或文件夹属性的记录地址,从而根据文件或文件夹属性的记录地址 将文件或文件夹属性读入内存中。
下面, 以 windows操作系统为例对前述的文件或文件夹查找方法进 行说明, 假设硬盘的分区釆用 NTFS格式, 需要在 C盘进行文件查找, 那么具体过程如下所述:
使用 Windows API CreateFile来打开目标驱动器,读取前 512个字节, 即引导记录区, 从第 25字节开始是 BPB文件, MFT的起始地址可以从 BPB中读取, 具体是 BPB中的第 49 - 57字节。 其中 BPB中的头两个字 节定义了每扇区字节数, 接下来的 2 个字节定义了每个簇有几个扇区, 第 41 字节到 49字节是此分区总共有多少扇区。 以上文件或文件夹可以 计算出每簇的大小 =每扇区字节数 *每个簇的扇区数, 每簇的大小通常是 4KB, 但在格式化时也可以指定为其它大小。 取得 MFT地址后再次调用 ReadFile来读取整个 MFT。 MFT的每个记录段长度为 1024个字节。
开始遍历 MFT来找到所有文件和文件夹。 具体方法是: 找到第一个 "FILE0" 开头的区域, 往后读取 512个字节, 所有与这个文件或文件夹 相关的属性全部在这 512个字节里, 包括文件名, 是否目录, 文件大小, 文件所占用的起始簇号, 占了多少个簇, 创建日期, 访问日期等等。 此 处, 只读前 512字节而不是 1024字节, 是因为后面 512节点是数据段, 一些小于 512字节的文件会被直接存在 MFT里, 对查找文件而言, 读取 前 512字节就可以实现查找。 然后往后偏移 1024字节读取下一个文件内 容, 以此类推, 直至所有文件信息读取完, 即可完成查找。
参照图 3 , 示出本发明的一种文件或文件夹查找装置实施例, 包括: 硬 盘分区格式获取模块 12、 记录获取模块 20和查找模块 30。
硬盘分区格式获取模块 12, 配置为获取硬盘分区格式。 其中, 硬盘 分区格式通常为 FAT12, FAT16 , FAT32和 NTFS。 优选地, 硬盘分区格 式获取模块 12包括主引导记录区内容读取模块 10,配置为读取主引导记 录区的内容, 从所述主引导记录的内容中获取硬盘分区格式。 硬盘分区 格式也可以在用户根据物理硬盘容量和自己的需要, 建立主分区、 扩展 分区和逻辑盘符并格式化处硬盘后, 将硬盘的分区格式信息预先存储在 硬盘或者内存中的非主引导记录区的地址 /地址段处, 并以供指定接口函 数访问该地址 /地址段, 来获取硬盘分区格式信息。 硬盘分区格式还可以 釆用其他第三方应用软件来识别获取, 当需要时从第三方应用软件提供 的接口函数获取。 可以理解的是, 硬盘分区格式还可以根据其他方式来 获取, 本发明对此并不限制。
记录获取模块 20, 配置为根据硬盘分区格式获取所有文件或文件夹 属性的记录地址, 并根据所述文件或文件夹属性的记录地址将所有文件 或文件夹属性读入内存。其中,当硬盘分区格式为 FAT12, FAT16或 FAT32 时, 记录获取模块 20为文件分配表记录获取模块, 配置为从文件分配表 获取所有文件或文件夹属性的记录地址。 当硬盘格式分区为 NTFS时,记 录获取模块 20为主文件表记录获取模块, 配置为当从主文件表中获取所 有文件或文件夹属性的记录地址。
查找模块 30 , 配置为在读入内存的所有文件或文件夹属性中遍历查 找全部或部分文件或文件夹。
参照图 4, 示出本发明的记录获取模块实施例一的结构示意图。 其中, 文件分配表记录获取模块包括文件分配表起始地址和大小获取模块 211、 记录地址确定模块 213和记录内容读取模块 215。 其中, 文件分配表起始 地址和大小获取模块 211 , 配置为读取 BPB的内容, 获取文件分配表的 起始地址和大小。 记录地址确定模块 213 , 配置为确定文件分配表中所有 文件或文件夹的记录起止地址。 记录内容读取模块 215 , 配置为根据确定 的所有文件或文件夹属性所在记录项的记录起止地址将文件分配表中所 有文件或文件夹属性读入内存。
参照图 5 , 示出本发明的记录获取模块实施例二的结构示意图。 其中, 主文件表记录获取模块包括主文件表起始地址和大小获取模块 231、记录 地址确定模块 233和记录内容读取模块 235。 其中, 主文件表起始地址和 大小获取模块 231 , 配置为读取 BPB的内容, 获取主文件表的起始地址 和大小。 记录地址确定模块 233 , 配置为确定主文件表所有文件或文件夹 的记录起止地址。 记录内容读取模块 235 , 配置为根据确定的所有文件或 文件夹属性所在记录项的记录起止地址将主文件表中所有文件或文件夹 属性读入内存。
另外, 主文件表记录获取模块也可以包括元文件打开模块 237, 配置 为打开元文件 $MFT 来获取整个主文件表的所有文件或文件夹属性的记 录地址, 并根据所述文件或文件夹属性的记录地址获取所述文件或文件 夹属性。 具体的, 可以通过 CreateFile函数打开元文件$^«^。
参照图 6, 图 6是本发明的文件或文件夹查找装置实施例二的结构示意 图。 进一步地, 查找模块 30包括文件或文件夹属性遍历模块 31和 /或属 性信息区域确定模块 33。 其中, 文件或文件夹属性遍历模块配置为遍历 每一个文件或文件夹属性, 获取文件或文件夹属性。 属性信息区域确定 模块, 配置为确定主文件表中文件或文件夹属性的存储位置,对所述存储位 置进行查找。
进一步地,文件或文件夹查找装置还包括查找条件添加模块 50和展示 模块 70。 查找条件添加模块 50, 配置为在查找时加入的文件或文件夹特征 作为查找条件。 例如, 文件名, 创建日期, 最后访问日期, 大小等等的查 找条件。 展示模块, 配置为展示查找到的文件或文件夹。
进一步地, 文件或文件夹查找装置还包括处理模块 80, 配置为删除 查找到的文件或文件夹。
进一步地, 文件或文件夹查找装置还包括文件或文件夹属性记录地址 获取模块 90, 配置为在出现新的硬盘分区格式,从服务器中获取文件或文件 夹属性的记录地址。
进一步地, 所述记录获取模块 20还包括一次读取模块 25 , 配置为将 所有文件或文件夹属一次读入内存; 或分段读取模块 27, 配置为将所有 文件或文件夹属性分段读入内存。
基于以上内容, 本发明还提供了一种在其上记录有用于执行上述文件 或文件夹查找方法的程序的计算机可读记录介质。 其中, 所述文件或文件 夹查找方法的具体内容可参见方法实施例所述的内容, 在此不作赘述。
所述计算机可读记录介质包括用于以计算机(例如计算机)可读的形式 存储或传送信息的任何机制。 例如, 机器可读介质包括只读存储器(ROM )、 随机存取存储器( RAM )、 磁盘存储介质、 光存储介质、 闪速存储介质、 电、 光、 声或其他形式的传播信号 (例如, 载波、 红外信号、 数字信号等)等。
本发明的文件或文件夹查找方法和装置通过读取主引导记录区中所 记载的文件或文件夹记录的起始地址和大小来确定每个文件或文件夹记 录的地址, 从而将所有文件或文件夹记录一次或分段读入到内存中, 然 后在内存中遍历所有的文件或文件夹记录来对文件进行查找。 此种方式 通过一次或几次 I/O操作来实现文件查找, 可以避免因为频繁进行 I/O操 作而造成的查找速度较慢的情况, 提高查找速度以及客户端的响应速度, 避免对客户端资源进行不必要的占用。 说明的都是与其他实施例的不同之处, 各个实施例之间相同相似的部分 互相参见即可。 对于装置实施例而言, 由于其与方法实施例基本相似, 所以描述的比较简单, 相关之处参见方法实施例的部分说明即可。
以上对本发明所提供的文件或文件夹查找方法和装置进行了详细介 以 上实施例的说明只是用于帮助理解本发明的方法及其核心思想之一; 同 时, 对于本领域的一般技术人员, 依据本发明的思想, 在具体实施方式 及应用范围上均会有改变之处, 综上所述, 本说明书内容不应理解为对 本发明的限制。

Claims

权 利 要 求 书
1、 一种文件或文件夹查找方法, 其特征在于, 包括以下步骤: 获取硬盘分区格式;
根据硬盘分区格式获取硬盘中所有文件或文件夹属性的记录地址; 并
根据所述文件或文件夹属性的记录地址将所有文件或文件夹属性读 入内存;
在读入内存的所有文件或文件夹属性中遍历查找全部或部分文件或 文件夹。
2、 如权利要求 1所述的方法, 其特征在于, 所述根据硬盘分区格式获 取硬盘中所有文件或文件夹属性的记录地址; 并根据所述文件或文件夹 属性的记录地址将所有文件或文件夹属性读入内存包括:
若硬盘分区格式为 FAT12, FAT16或 FAT32, 从文件分配表获取所有 文件或文件夹属性的记录地址, 并根据文件或文件夹属性的记录地址将 文件分配表中的所有文件或文件夹属性读入内存; 和 /或
若硬盘分区格式为 NTFS ,从主文件表中获取所有文件或文件夹属性 的记录地址, 并根据文件或文件夹属性的记录地址将主文件表中的所有 文件或文件夹属性读入内存。
3、 如权利要求 2所述的方法, 其特征在于, 所述从文件分配表获取所 有文件或文件夹属性的记录地址, 并根据文件或文件夹属性的记录地址 将文件分配表中的所有文件或文件夹属性读入内存包括:
读取 BIOS参数块的内容, 获取文件分配表的起始地址和大小; 确定文件分配表中所有文件或文件夹属性所在记录项的记录起止地 址;
根据确定的所有文件或文件夹属性所在记录项的记录起止地址将文 件分配表中所有文件或文件夹属性读入内存。
4、 如权利要求 2所述的方法, 其特征在于, 所述从主文件表中获取所 有文件或文件夹属性的记录地址, 并根据文件或文件夹属性的记录地址 将主文件表中的所有文件或文件夹属性读入内存包括: 读取 BIOS参数块的内容, 获取主文件表的起始地址和大小; 确定主文件表中所有文件或文件夹属性所在记录项的记录起止地 址;
根据确定的所有文件或文件夹属性所在记录项的记录起止地址将主 文件表中所有文件或文件夹属性读入内存。
5、 如权利要求 2所述的方法, 其特征在于, 所述从主文件表中获取所 有文件或文件夹属性的记录地址, 并根据文件或文件夹属性的记录地址 将主文件表中的所有文件或文件夹属性读入内存包括:
打开元文件 $MFT 来获取整个主文件表的所有文件或文件夹属性所 在记录项的记录地址, 并根据所述文件或文件夹属性所在记录项的记录 地址获取所述文件或文件夹属性。
6、 如权利要求 1所述的方法, 其特征在于, 所述获取硬盘分区格式包 括:
读取主引导记录区的内容, 从所述主引导记录的内容中获取硬盘分 区格式。
7、 如权利要求 2所述的方法, 其特征在于, 所述在读入内存的所有文 件或文件夹属性中遍历查找全部或部分文件或文件夹包括:
确定文件分配表或主文件表的起始地址;
从起始地址开始, 依次偏移文件或文件夹属性所在记录项所占用的 字节数, 直至遍历完成。
8、 如权利要求 7所述的方法, 其特征在于, 所述在读入内存的所有文 件或文件夹属性中遍历查找全部或部分文件或文件夹包括:
确定主文件表中文件或文件夹属性在其所在记录项中的存储位置,在所 述存储位置进行查找。
9、 如权利要求 1所述的方法, 其特征在于, 所述在读入内存的所有文 件或文件夹属性中遍历查找全部或部分文件或文件夹包括:
根据在查找时加入的文件或文件夹特征作为查找条件, 在读入内存的 所有文件或文件夹属性中遍历查找全部或部分文件或文件夹。
10、 如权利文件 9所述的方法, 其特征在于, 所述查找条件包括以下一 种或多种: 文件名、 文件夹名、 创建日期、 最后访问日期和大小。
11、 如权利要求 10所述的方法, 其特征在于, 所述指定文件或文件夹 的查找包括以下一种或几种:
重复文件或文件夹查找、 0字节文件或文件夹查找、 指定文件或文件夹 查找, 以及垃圾文件查找。
12、 如权利要求 11 所述的方法, 其特征在于, 所述方法还包括删除所 述查找到的文件或文件夹。
13、 如权利要求 1所述的方法, 其特征在于, 所述方法还包括: 若出现新的硬盘分区格式,从服务器中获取文件或文件夹属性的记录地 址。
14、 如权利要求 1 所述的方法, 其特征在于, 所述硬盘中所有文件或 文件夹属性包括以下一种或多种:
名称、 大小、 创建时间、 创建日期、 最后访问日期、 最后修改日期。
15、 如权利要求 14所述的方法, 其特征在于, 所述方法还包括: 根据硬盘分区格式获取硬盘中所有文件或文件夹的存放位置。
16、 如权利要求 1至 15任一项所述的方法, 其特征在于, 所述将所 有文件或文件夹属性读入内存包括:
将所有文件或文件夹属性一次读入内存; 或
将所有文件或文件夹属性分段读入内存。
17、 一种文件或文件夹查找装置, 其特征在于, 包括:
硬盘分区格式获取模块, 配置为获取硬盘分区格式;
记录获取模块, 配置为根据硬盘分区格式获取硬盘中所有文件或文 件夹属性的记录地址; 并根据所述文件或文件夹属性的记录地址将所有 文件或文件夹属性读入内存;
查找模块, 配置为在读入内存的所有文件或文件夹属性中遍历查找 全部或部分文件或文件夹。
18、如权利要求 17所述的装置, 其特征在于, 所述记录获取模块包括: 文件分配表记录获取模块, 配置为当硬盘分区格式为 FAT12, FAT16 或 FAT32时, 从文件分配表获取所有文件或文件夹属性的记录地址, 并 根据文件或文件夹属性的记录地址将文件分配表中的所有文件或文件夹 属性读入内存; 和 /或
主文件表记录获取模块, 配置为当硬盘分区格式为 NTFS时,从主文 件表中获取所有文件或文件夹属性的记录地址和属性, 并根据文件或文 件夹属性的记录地址将主文件表中的所有文件或文件夹属性读入内存。
19、 如权利要求 18所述的装置, 其特征在于, 所述文件分配表记录获 取模块包括:
文件分配表起始地址和大小获取模块,配置为读取 BIOS参数块的内 容, 获取文件分配表的起始地址和大小;
记录地址确定模块, 配置为确定文件分配表中所有文件或文件夹属性 所在记录项的记录起止地址;
记录内容读取模块, 配置为根据确定的所有文件或文件夹属性所在 记录项的记录起止地址将文件分配表中所有文件或文件夹属性读入内 存。
20、 如权利要求 18所述的装置, 其特征在于, 所述主文件表记录获取 模块包括:
主文件表起始地址和大小获取模块, 配置为读取 BIOS 参数块的内 容, 获取主文件表的起始地址和大小;
记录地址确定模块, 配置为确定主文件表所有文件或文件夹属性所在 i己录项的 i己录起止地址;
记录内容读取模块, 配置为根据确定的所有文件或文件夹属性所在 记录项的记录起止地址将主文件表中所有文件或文件夹属性读入内存。
21、 如权利要求 18所述的装置, 其特征在于, 所述主文件表记录获取 模块包括:
元文件打开模块, 配置为打开元文件 $MFT 来获取整个主文件表的所 有文件或文件夹属性的记录地址, 并根据所述文件或文件夹属性的记录 地址获取所述文件或文件夹属性。
22、 如权利要求 17所述的装置, 其特征在于, 所述硬盘分区格式获取 模块包括:
主引导记录区内容读取模块, 配置为读取主引导记录区的内容, 从 所述主引导记录的内容中获取硬盘分区格式。
23、 如权利要求 17所述的装置, 其特征在于, 所述查找模块包括: 属性信息区域确定模块, 配置为确定主文件表中文件或文件夹属性在 其所在记录项中的存储位置, 对所述存储位置进行查找。
24、 如权利要求 17所述的装置, 其特征在于, 所述装置还包括: 查找条件添加模块, 配置为根据在查找时加入的文件或文件夹特征作 为查找条件,在读入内存的所有文件或文件夹属性中遍历查找全部或部分 文件或文件夹; 和
展示模块, 配置为展示查找到的文件或文件夹。
25、 如权利要求 24所述的装置, 其特征在于, 所述装置还包括: 处理模块, 配置为删除查找到的文件或文件夹。
26、 如权利要求 17所述的装置, 其特征在于, 所述装置还包括: 文件或文件夹属性记录地址获取模块, 配置为在出现新的硬盘分区格 式, 从服务器中获取文件或文件夹属性的记录地址。
27、 如权利要求 17至 26任一项所述的装置, 其特征在于, 所述记录获 取模块包括:
一次读取模块, 配置为将所有文件或文件夹属性一次读入内存; 或 分段读取模块, 配置为将所有文件或文件夹属性分段读入内存。
28、一种在其上记录有用于执行权利要求 1所述方法的程序的计算机可 读记录介质。
PCT/CN2012/076359 2011-06-17 2012-05-31 文件或文件夹查找方法和装置 Ceased WO2012171434A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201110163954.0 2011-06-17
CN2011101639540A CN102289451A (zh) 2011-06-17 2011-06-17 文件或文件夹查找方法和装置

Publications (1)

Publication Number Publication Date
WO2012171434A1 true WO2012171434A1 (zh) 2012-12-20

Family

ID=45335883

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2012/076359 Ceased WO2012171434A1 (zh) 2011-06-17 2012-05-31 文件或文件夹查找方法和装置

Country Status (2)

Country Link
CN (1) CN102289451A (zh)
WO (1) WO2012171434A1 (zh)

Families Citing this family (15)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102289451A (zh) * 2011-06-17 2011-12-21 奇智软件(北京)有限公司 文件或文件夹查找方法和装置
CN103198119A (zh) * 2013-04-02 2013-07-10 浪潮电子信息产业股份有限公司 一种快速查找具有相同重复数据删除标识的所有链接文件的方法
CN104699688A (zh) * 2013-12-04 2015-06-10 杭州鹰湾科技有限公司 一种搜索文件的方法和电子设备
CN105589888B (zh) * 2014-10-24 2020-10-16 中兴通讯股份有限公司 一种设备中管理文件的方法和装置
CN104915462A (zh) * 2015-07-14 2015-09-16 魅族科技(中国)有限公司 一种文件管理方法及系统
CN105868820A (zh) * 2015-12-15 2016-08-17 乐视移动智能信息技术(北京)有限公司 U盘设备识别方法、装置及移动设备
CN106446014B (zh) * 2016-08-26 2020-01-07 维沃移动通信有限公司 一种文件查找方法及移动终端
CN107168905B (zh) * 2017-05-11 2020-08-21 Oppo广东移动通信有限公司 一种文件显示方法、装置、存储介质及移动终端
CN108647280A (zh) * 2018-05-03 2018-10-12 北京云中融信网络科技有限公司 一种存储通讯信息的方法和装置
CN108763413B (zh) * 2018-05-23 2021-07-23 唐山高新技术产业园区兴荣科技有限公司 基于数据存储格式的数据查找定位方法
CN110334065B (zh) * 2019-07-11 2022-02-11 中国联合网络通信集团有限公司 一种文件处理方法和系统
CN110825699A (zh) * 2019-11-08 2020-02-21 北京天地和兴科技有限公司 一种在c#程序中快速统计磁盘文件数量的方法
CN112181910B (zh) * 2020-09-25 2024-06-04 炬芯科技股份有限公司 一种扩展短文件名生成方法、文件访问方法以及设备
CN112307033B (zh) * 2020-11-23 2023-04-25 杭州迪普科技股份有限公司 数据包文件的重构方法、装置及设备
CN114416656A (zh) * 2021-12-24 2022-04-29 新华三云计算技术有限公司 一种远程操作文件夹的方法、设备及存储介质

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1776686A (zh) * 2005-12-16 2006-05-24 北京中星微电子有限公司 Fat文件系统中基于位置的接口访问方法及其装置
CN101650737A (zh) * 2009-09-15 2010-02-17 福州瑞芯微电子有限公司 基于fat系统的快速打开文件的方法
CN102289451A (zh) * 2011-06-17 2011-12-21 奇智软件(北京)有限公司 文件或文件夹查找方法和装置

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN100442393C (zh) * 1999-10-21 2008-12-10 松下电器产业株式会社 半导体存储卡的访问装置、初始化方法和半导体存储卡

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1776686A (zh) * 2005-12-16 2006-05-24 北京中星微电子有限公司 Fat文件系统中基于位置的接口访问方法及其装置
CN101650737A (zh) * 2009-09-15 2010-02-17 福州瑞芯微电子有限公司 基于fat系统的快速打开文件的方法
CN102289451A (zh) * 2011-06-17 2011-12-21 奇智软件(北京)有限公司 文件或文件夹查找方法和装置

Also Published As

Publication number Publication date
CN102289451A (zh) 2011-12-21

Similar Documents

Publication Publication Date Title
CN102289451A (zh) 文件或文件夹查找方法和装置
JP5242686B2 (ja) 直接大容量記憶装置ファイルインデックス処理
US9798496B2 (en) Methods and systems for efficiently storing data
CN103154948B (zh) 可丢弃文件的基于卡的管理
US9348837B2 (en) Index writing in a linear tape file system
CN102667772A (zh) 文件级分级存储管理系统、方法和设备
CN103279532B (zh) 多集合元素去重并标识所属集合的过滤系统及其方法
US10521126B2 (en) Systems and methods for writing back data to a storage device
CN102880714A (zh) 文件清理方法及装置
WO2017185579A1 (zh) 一种数据存储方法及装置
WO2012149884A1 (zh) 文件系统和检索、写入、修改或删除文件的方法与装置
US20170286442A1 (en) File system support for file-level ghosting
CN107817946B (zh) 用于混合存储设备读写数据的方法以及装置
WO2020103493A1 (zh) 基于fat32文件系统的删除文件恢复方法及系统
US20190272258A1 (en) Region-integrated data deduplication implementing a multi-lifetime duplicate finder
US20070112890A1 (en) Computerized system and method for document management
JP2025511879A (ja) 時系列データ階層化ストレージシステム及び方法
CN106709014A (zh) 一种文件系统转换方法及装置
EP1586988A2 (en) Information processing apparatus, information processing method, program and recording medium used therewith
JP4502375B2 (ja) ファイルシステムおよびその制御方法
JP2019537097A (ja) Iノードのアクセスパターンの追跡及びiノードの先取り
CN112286448B (zh) 对象访问方法、装置、电子设备及机器可读存储介质
CN104537023B (zh) 一种反向索引记录的存储方法及装置
CN115826877A (zh) 大数据环境下的数据对象迁移方法和装置
EP3436990B1 (en) Systems and methods for enabling modifications of multiple data objects within a file system volume

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 12800139

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 12800139

Country of ref document: EP

Kind code of ref document: A1