CN102402543A - File searching method and device - Google Patents

File searching method and device Download PDF

Info

Publication number
CN102402543A
CN102402543A CN2010102827218A CN201010282721A CN102402543A CN 102402543 A CN102402543 A CN 102402543A CN 2010102827218 A CN2010102827218 A CN 2010102827218A CN 201010282721 A CN201010282721 A CN 201010282721A CN 102402543 A CN102402543 A CN 102402543A
Authority
CN
China
Prior art keywords
file
search
information
searches
last
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.)
Granted
Application number
CN2010102827218A
Other languages
Chinese (zh)
Other versions
CN102402543B (en
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.)
Wuxi Vimicro Corp
Original Assignee
Wuxi Vimicro Corp
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 Wuxi Vimicro Corp filed Critical Wuxi Vimicro Corp
Priority to CN201010282721.8A priority Critical patent/CN102402543B/en
Publication of CN102402543A publication Critical patent/CN102402543A/en
Application granted granted Critical
Publication of CN102402543B publication Critical patent/CN102402543B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Abstract

The invention discloses a file searching method and device, which are used for increasing file searching speed. The method comprises the steps of: acquiring the information of a last file which is searched last time, determining an initial file under the current search path according to the information of the last file, searching a next file from the initial file, updating the number of searched files, comparing the updated number with a set value, returning the information of all the searched files and the number of the searched files the when the number reaches the set value.

Description

A kind of method of search file and device
Technical field
The present invention relates to field of computer technology, particularly a kind of method of search file and device.
Background technology
At mobile phone; In the multimedia processing system of handheld devices such as PMP, need dir on some upper layer application interfaces, this just need be in the storage medium of these handheld devices; Carry out the search of disk file; The popularization and application of the storage medium that can dynamically plug along with usb and sd card etc., the file on the disk all might be changed at any time, and this just needs disposal system at any time disk file to be searched for.
The another one aspect, along with the capacity of storage medium is increasing, the number of files that can preserve on the storage medium is also more and more, the reaction time the when speed of search file is directly connected to the upper layer application interface display.At present; The interface of the search file that the file system in the general multimedia processing system provides has two; Be respectively: findfirst and findnext; The characteristics of these two interfaces are exactly to search a file or file at every turn, and in search procedure, the upper layer application in the multimedia processing system needs frequent this two purposes that interface realizes searching for the whole magnetic disk All Files of calling; For example: disk has 1000 files, in search procedure, just need call 1000 findfirst and findnext so.Every search once; Upper layer application in the multimedia processing system just with file system alternately once, obtain the information of a file, like this; Under the many situation of disk file; Upper layer application in the multimedia processing system just need be carried out repeatedly alternately with file system, has caused the great amount of time resource consumption, has influenced the speed of search.
Summary of the invention
The embodiment of the invention provides a kind of method and device of search file, in order to improve the speed of file search.
The embodiment of the invention provides a kind of method of search file, comprising:
Obtain the information of last file that searched last time;
According to the information of said last file, confirm the initial file under the current search path;
Begin from said initial file, search for next file, and upgrade the number of the file that searches; Number and setting value after upgrading are compared; When said number reaches setting value, return the information of all files that search, and the number of the file that searches.
The embodiment of the invention provides a kind of device of file search, comprising:
Acquiring unit is used to obtain the information of last file that searched last time;
Confirm the unit, be used for information, confirm the initial file under the current search path according to said last file;
Search unit is used for beginning from said initial file, searches for next file; And upgrade the number of the file search, number and setting value after upgrading are compared, when said number reaches setting value; Return the information of all files that search, and the number of the file that searches.
In the embodiment of the invention, obtain the information of last file that searched last time, according to the information of last file; Confirm the initial file under the current search path, begin, search for next file from said initial file; And upgrade the number of the file search, number and setting value after upgrading are compared, when said number reaches setting value; Return the information of all files that search, and the number of the file that searches, like this; Whenever search after the file, the upper layer application in the multimedia processing system is not to carry out alternately with file system at once, obtains the information of this document; Just when the number of the file that searches equates with setting value, the upper layer application ability in the medium processing system and file system alternately once obtain the information that all search file.Thereby, when realizing a plurality of file searches, reduced the interaction times of the upper layer application in the multimedia processing system and file system, saved the time of searching for, improved the speed of file search.
Description of drawings
Fig. 1 is the process flow diagram of search file in the embodiment of the invention;
Fig. 2 is the process flow diagram of search file in the specific embodiment of the invention;
Fig. 3 is the structural drawing of search file device in the embodiment of the invention.
Embodiment
In the embodiment of the invention; After having set the path of search file in the upper layer application in the multimedia processing system and having needed the number of search file; Application programming interfaces (API, Application Programming Interface) through embodiment of the invention file system provides are once searched for, and just can obtain the information of a plurality of files; Reduced mobile phone; The upper layer application in the multimedia processing system of handheld devices such as PMP and the interaction times of file system have been saved the time of search, have improved the speed of file search.
In the embodiment of the invention, the definition of file is broad sense relatively, having comprised: file, file, and in the file directory one or more.
In the embodiment of the invention; The path and the number that needs search file of search file have been set in the upper layer application; Be that API in the embodiment of the invention has confirmed the current search path, and confirmed that needing the number of search file is setting value, so; The process of this API search file specifically comprises referring to Fig. 1:
Step 101: the information of obtaining last file that searched last time.
Here, the information of file comprises: the path at filename, file attribute, file size and file place.
When for the first time beginning search file, there is not last file of searching last time, the fileinfo that then obtains is empty information.
When not being when for the first time beginning search file; Because after each search; All give the upper layer application in the multimedia processing system with the information feedback of the All Files that searches, promptly upper layer application has all been obtained the information of all files that search from file system, and the number of the file that searches; Therefore, the upper layer application in the multimedia processing system has been preserved the information of last file that searched last time.
Here; The information of the file that searched from the last time that upper layer application is preserved; Obtain the information of last file that searched last time, specifically comprise: from upper layer application, duplicate the information of last file that searched (COPY) last time, and revised file internal system parameter.
Step 102:, confirm the initial file under the current search path according to the information of last file.
Comprised the path at file place in the information of last file, this path and current search path have been mated, when both are consistent; Confirm that initial file is last file that obtains; When both are inconsistent, show it is under the current search path, to search for for the first time, therefore; Initial file under the current search path is zero, promptly needs the search that under the current search path, starts anew.
Step 103: begin from initial file, search for next file, and upgrade the number of the file that searches.
Here, before searching for, the number of the file that this searches is zero, whenever search a file after, just the number with the file that searches adds 1, promptly searches a file, just the number of the file that once searches of renewal.
The procedure file internal system of search still need be called these two interfaces of findfirst and findnext.Whenever search a file, the temporary transient not upper layer application in multimedia processing system is returned the information of this document, just upgrades the number of the file that searches.
Step 104: whether the number of the file that searches after judge upgrading equate with setting value, if, execution in step 105, otherwise, the file that searches as initial file, is returned step 103.
Before this search, set the path and the number that needs search file of search file in the upper layer application, promptly the API in the embodiment of the invention has confirmed that needing the number of search file is setting value; Here, the number and the setting value of the file that searches compared, if the number of the file that searches equates with setting value; The target that then can confirm this search is reached, execution in step 105, otherwise; Also need proceed search, the file that searches as initial file, is returned step 103; Be about to current this file that searches out as initial file, return step 103.
Step 105: return the information of all files that search, and the number of the file that searches, this search procedure finishes.
The number of the file that searches has equated with setting value; Need the number of the file of search to reach; Therefore, obtain the information of all files that search, and the number of the file that searches; And with the information of all files that search, and the number of the file that searches returns to upper layer application.
Like this, upper layer application can be preserved the information of this last file that searches, like this, so that file search next time.
In the embodiment of the invention; Whenever search after the file; File system is not to give the upper layer application in the multimedia processing system with the information feedback of this document at once; Just when the number of the file that searches equates with setting value, the upper layer application of medium processing system ability and file system alternately once obtain the information that all search file.Thus it is clear that, in the process of search, though these two interfaces of findfirst and findnext have also repeatedly been called in file system inside; But, the upper layer application of medium processing system and file system alternately for once, promptly only call the API that embodiment of the invention file system provides; Thereby, when realizing a plurality of file searches, reduced the interaction times of upper layer application and the file system of multimedia processing system; Save the time of search, improved the speed of file search.
In the embodiment of the invention, need the number of the file of search, promptly setting value is generally confirmed according to the internal memory of multimedia processing system; If setting value is too big; The information of the file that searches that upper layer application is obtained will be occupied too many memory headroom, is unfavorable for the operation of multimedia processing system, if setting value is too little; The information of the file that searches that then once obtains can not significantly improve the speed of file search very little.
In the search procedure of the foregoing description,, may obtain information less than all files that search if when the number of All Files under the current search path can not reach setting value; And the number of the file that searches, therefore, in the embodiment of the invention; Before above-mentioned steps 104, need judge also whether the file that searches is last file under the current search path, promptly judge whether also have file under the current search path; If the file that searches is last file under the current search path; So, direct execution in step 105 is returned the information of all files that search; And the number of the file that searches, do not need to have carried out follow-up step 104 again.
At this moment, returned the information of all files that search, and after the number of the file that searches; Because the number of the file that searches possibly also not reach setting value, then whether upper layer application can still proceed search according to the practical application decision, if confirm still to proceed search; So, the number and the setting value of the file that searches that upper layer application will be obtained compare, if less than setting value; Then specify next searching route, like this, the API that embodiment of the invention file system provides can instruct according to this; With the current search routing update is next searching route, proceeds search, reaches setting value until the number of the file that searches.Certainly, if confirm no longer to have searched for, this searches for end.Perhaps, the number of the file that searches reaches setting value, then also need not search for, and this searches for end.
Before the foregoing description is searched for; Multimedia processing system possibly carry out other upper level applications; The disk of work at present is not necessarily and current search path corresponding search disk so; When search disk and work at present disk do not match, must the work at present disk be switched to the search disk.
Below in conjunction with Figure of description the embodiment of the invention is described in further detail.
In the present embodiment, confirmed the current search path, and confirmed that needing the number of search file is setting value.Referring to Fig. 2, the process of search file comprises:
Step 201: confirm the current plain path corresponding search disk of searching.
If in the present embodiment, multimedia processing system is supported the file system of two disks, and A is a disk 1, and B is a disk 2, so, if the current search path is (" A:/abc/123 "), confirms that then the corresponding search disk is a disk 1.
Step 202: judge whether the search disk is consistent with the work at present disk, if consistent, execution in step 204, otherwise execution in step 203.
If in the present embodiment, the work at present disk is a disk 1, consistent with the search disk so, directly execution in step 204 is inconsistent with the search disk so if the work at present disk is a disk 2, execution in step 203.
Step 203: the work at present disk is switched to the search disk, and change execution in step 204 over to.
Step 204: the information of obtaining last file that searched last time.
Step 205:, confirm the initial file under the current search path according to the information of last file that searched the last time of preserving.
Step 206: begin from initial file, search for next file, and upgrade the number of the file that searches.
Step 207: judge whether the file that searches is last file under the current search path, if, execution in step 209, otherwise, execution in step 208.
Step 208: whether the number of judging the file search equate with setting value, if, execution in step 209, otherwise, the file that searches as initial file, is returned step 206.
Step 209: with the information of all files that search, and the number of the file that searches returns to upper layer application, and this search procedure finishes.
If in the present embodiment, setting number is 10, only searches 8 files under the current search path; So, when step 209 is returned the information of all files that search, and after the number of the file that searches; Can also be with instruction according to upper layer application; With the current search routing update is next searching route, continues search then, until searching 10 files.
In above-mentioned each embodiment, with mobile phone, the multimedia processing system of handheld devices such as PMP is that example is described, but the invention is not restricted to this, and the disposal system of other intelligent terminal also can be used.
According to the method for above-mentioned search file, can make up a kind of device of search file, referring to Fig. 3, comprising: acquiring unit 100, confirm unit 200 and search unit 300.Wherein,
Acquiring unit 100 is used to obtain the information of last file that searched last time.
Confirm unit 200, be used for information, confirm the initial file under the current search path according to said last file.
Search unit 300; Be used for beginning, search for next file, and upgrade the number of the file that searches from said initial file; Number and setting value after upgrading are compared; When said number reaches setting value, return the information of all files that search, and the number of the file that searches.
Should confirm that unit 200 comprised:
First matching unit is used for the path and the said current search path at the file place of the information of said last file are mated.
Confirm subelement, be used for when both are consistent, confirming that initial file is said last file, when both are inconsistent, confirm that initial file is zero.
Certainly, in the embodiment of the invention, if when the number of All Files under the current search path can not reach setting value; May obtain information less than all files that search, and the number of the file that searches, therefore; In the embodiment of the invention, search unit 300 is used to also judge whether the file that searches is last file under the current search path; If, obtain the information of all files that search, and the number of the file that searches.
Obtain the information of all files that search; And after the number of the file that searches; Because the number of the file that searches possibly also not reach setting value; Can be next searching route then, proceed search, reach setting value until the number of the file that searches with the current search routing update.Therefore, search unit 300, also being used for said current search routing update is next searching route.
This device is before searching for; Multimedia processing system possibly carry out other upper level applications; The disk of work at present is not necessarily and current search path corresponding search disk so, when search disk and work at present disk do not match, must the work at present disk be switched to the search disk; Therefore, this device also comprises:
Switch unit when being used for as if do not match with current search path corresponding search disk and work at present disk, switches to said search disk with said work at present disk.
The device of the search file in the embodiment of the invention can be applied in the multimedia processing system, the API that provides corresponding to file system.But the invention is not restricted to this, also can use in the disposal system of intelligent terminal with other.
In the embodiment of the invention, obtain the information of last file that searched last time, according to the information of last file; Confirm the initial file under the current search path, begin, search for next file from said initial file; And upgrade the number of the file search, number and setting value after upgrading are compared, when said number reaches setting value; Return the information of all files that search, and the number of the file that searches, when said number does not reach setting value; Continue the next file of search, reach said setting value until the number of the file that searches, like this; Whenever search after the file, the upper layer application of multimedia processing system is not to carry out alternately with file system at once, obtains the information of this document; Just when the number of the file that searches equates with setting value, the upper layer application ability in the medium processing system and file system alternately once obtain the information that all search file.Thereby, when realizing a plurality of file searches, reduced the interaction times of multimedia processing system and file system, saved the time of search, improved the speed of file search.
Obviously, those skilled in the art can carry out various changes and modification to the present invention and not break away from the spirit and scope of the present invention.Like this, belong within the scope of claim of the present invention and equivalent technologies thereof if of the present invention these are revised with modification, then the present invention also is intended to comprise these changes and modification interior.

Claims (10)

1. the method for a search file is characterized in that, comprising:
Obtain the information of last file that searched last time;
According to the information of said last file, confirm the initial file under the current search path;
Begin from said initial file, search for next file, and upgrade the number of the file that searches; Number and setting value after upgrading are compared; When said number reaches setting value, return the information of all files that search, and the number of the file that searches.
2. the method for claim 1 is characterized in that, the initial file under said definite current search path comprises:
The path and the said current search path at the place of the file in the information of said last file are mated;
When both are consistent, confirm that initial file is said last file;
When both are inconsistent, confirm that initial file is zero.
3. the method for claim 1 is characterized in that, before number after said will the renewal and setting value compare, also comprises:
Judge whether the file that searches is last file under the current search path;
If, obtain the information of all files that search, and the number of the file that searches;
Otherwise, the step that number after execution will be upgraded and setting value compare.
4. method as claimed in claim 3 is characterized in that, the said information of returning all files that search, and after the number of the file that searches, also comprise:
With said current search routing update is next searching route.
5. like the described arbitrary method of claim 1-4, it is characterized in that, before the said information of obtaining last file that searched last time, also comprise:
To mate with current search path corresponding search disk and work at present disk;
When both are inconsistent, said work at present disk is switched to said search disk.
6. the device of a search file is characterized in that, comprising:
Acquiring unit is used to obtain the information of last file that searched last time;
Confirm the unit, be used for information, confirm the initial file under the current search path according to said last file;
Search unit is used for beginning from said initial file, searches for next file; And upgrade the number of the file search, number and setting value after upgrading are compared, when said number reaches setting value; Return the information of all files that search, and the number of the file that searches.
7. device as claimed in claim 6 is characterized in that, said definite unit comprises:
First matching unit is used for the path and the said current search path at the file place of the information of said last file are mated;
Confirm subelement, be used for when both are consistent, confirming that initial file is said last file, when both are inconsistent, confirm that initial file is zero.
8. device as claimed in claim 6 is characterized in that,
Said search unit is used to also judge whether the file that searches is last file under the current search path, if, obtain the information of all files that search, and the number of the file that searches.
9. device as claimed in claim 8 is characterized in that,
Said search unit, also being used for said current search routing update is next searching route.
10. like the described arbitrary device of claim 6-9, it is characterized in that, also comprise:
Switch unit when being used for as if do not match with current search path corresponding search disk and work at present disk, switches to said search disk with said work at present disk.
CN201010282721.8A 2010-09-14 2010-09-14 A kind of method of search file and device Active CN102402543B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201010282721.8A CN102402543B (en) 2010-09-14 2010-09-14 A kind of method of search file and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201010282721.8A CN102402543B (en) 2010-09-14 2010-09-14 A kind of method of search file and device

Publications (2)

Publication Number Publication Date
CN102402543A true CN102402543A (en) 2012-04-04
CN102402543B CN102402543B (en) 2016-02-03

Family

ID=45884757

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201010282721.8A Active CN102402543B (en) 2010-09-14 2010-09-14 A kind of method of search file and device

Country Status (1)

Country Link
CN (1) CN102402543B (en)

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP0798654A1 (en) * 1996-03-29 1997-10-01 Sun Microsystems, Inc. Converting handle-based find first/find next/find close to non-handle based find first/find next
EP0805392A1 (en) * 1996-05-01 1997-11-05 Sun Microsystems, Inc. Smart, least-recently-used method for reusing directory search handles
CN1776686A (en) * 2005-12-16 2006-05-24 北京中星微电子有限公司 Position-based interface access method and device for FAT file system
US20070027929A1 (en) * 2005-08-01 2007-02-01 Whelan Gary J System, method, and/or computer program product for a file system interface
US20070124295A1 (en) * 2005-11-29 2007-05-31 Forman Ira R Systems, methods, and media for searching documents based on text characteristics

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP0798654A1 (en) * 1996-03-29 1997-10-01 Sun Microsystems, Inc. Converting handle-based find first/find next/find close to non-handle based find first/find next
EP0805392A1 (en) * 1996-05-01 1997-11-05 Sun Microsystems, Inc. Smart, least-recently-used method for reusing directory search handles
US20070027929A1 (en) * 2005-08-01 2007-02-01 Whelan Gary J System, method, and/or computer program product for a file system interface
US20070124295A1 (en) * 2005-11-29 2007-05-31 Forman Ira R Systems, methods, and media for searching documents based on text characteristics
CN1776686A (en) * 2005-12-16 2006-05-24 北京中星微电子有限公司 Position-based interface access method and device for FAT file system

Also Published As

Publication number Publication date
CN102402543B (en) 2016-02-03

Similar Documents

Publication Publication Date Title
US11068441B2 (en) Caseless file lookup in a distributed file system
EP3483737A1 (en) Method and apparatus for processing object information, and storage medium
CN102750174B (en) file loading method and device
CN105760199B (en) A kind of application resource loading method and its equipment
CN105718484A (en) File writing method, file reading method, file deletion method, file query method and client
CN105867947A (en) Data processing method and device after upgrades of preset applications
US11086638B2 (en) Method and apparatus for loading application
EP3210103A1 (en) Disk partition stitching and rebalancing using a partition table
CN105740425A (en) File storage method and apparatus
CN105373595B (en) data self-classification storage method and terminal
CN103500191A (en) Flow table configuration, query and table item deleting method and device
CN101944000A (en) Method and device for arranging icons
CN103500116A (en) Method and system for clearing data generated by application program
CN104699423A (en) Method and device for binding disk drive in Linux system
CN107247722B (en) File scanning method and device and intelligent terminal
CN108540509B (en) Processing method and device of terminal browser, server and intelligent terminal
CN107632872B (en) Desktop layout processing method, user data processing method and device and computer storage medium
CN104461505A (en) Terminal
CN103425512A (en) Software package management method and system
CN104679900A (en) Application program searching method and device
CN105677421A (en) Customizing method and system of launchers of mobile terminal
CN102929981A (en) Media scanned file indexing method and device
CN103902562A (en) Method and device for upgrading terminal databases
CN102073731A (en) File processing method and terminal
CN103685400A (en) Information processing method, server and electronic equipment

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
CB02 Change of applicant information

Address after: 214028 national integrated circuit design (21-1), Changjiang Road, New District, Jiangsu, Wuxi, China, China (610)

Applicant after: WUXI ZHONGGAN MICROELECTRONIC CO., LTD.

Address before: 214028 national integrated circuit design (21-1), Changjiang Road, New District, Jiangsu, Wuxi, China, China (610)

Applicant before: Wuxi Vimicro Co., Ltd.

COR Change of bibliographic data
C14 Grant of patent or utility model
GR01 Patent grant