WO2019019341A1 - 文件存储方法、终端和计算机可读存储介质 - Google Patents

文件存储方法、终端和计算机可读存储介质 Download PDF

Info

Publication number
WO2019019341A1
WO2019019341A1 PCT/CN2017/103545 CN2017103545W WO2019019341A1 WO 2019019341 A1 WO2019019341 A1 WO 2019019341A1 CN 2017103545 W CN2017103545 W CN 2017103545W WO 2019019341 A1 WO2019019341 A1 WO 2019019341A1
Authority
WO
WIPO (PCT)
Prior art keywords
file
directory
value
storage
directories
Prior art date
Application number
PCT/CN2017/103545
Other languages
English (en)
French (fr)
Inventor
易周成
Original Assignee
平安科技(深圳)有限公司
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 平安科技(深圳)有限公司 filed Critical 平安科技(深圳)有限公司
Priority to US16/318,696 priority Critical patent/US20200293490A1/en
Priority to SG11201902727TA priority patent/SG11201902727TA/en
Publication of WO2019019341A1 publication Critical patent/WO2019019341A1/zh

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/11File system administration, e.g. details of archiving or snapshots
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/11File system administration, e.g. details of archiving or snapshots
    • G06F16/122File system administration, e.g. details of archiving or snapshots using management policies
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR 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
    • G06F16/137Hash-based
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/14Details of searching files based on file metadata
    • G06F16/144Query formulation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/16File or folder operations, e.g. details of user interfaces specifically adapted to file systems
    • G06F16/164File meta data generation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/16File or folder operations, e.g. details of user interfaces specifically adapted to file systems
    • G06F16/164File meta data generation
    • G06F16/166File name conversion
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/90Details of database functions independent of the retrieved data types
    • G06F16/901Indexing; Data structures therefor; Storage structures
    • G06F16/9017Indexing; Data structures therefor; Storage structures using directory or table look-up
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F7/00Methods or arrangements for processing data by operating upon the order or content of the data handled
    • G06F7/60Methods or arrangements for performing computations using a digital non-denominational number representation, i.e. number representation without radix; Computing devices using combinations of denominational and non-denominational quantity representations, e.g. using difunction pulse trains, STEELE computers, phase computers
    • G06F7/72Methods or arrangements for performing computations using a digital non-denominational number representation, i.e. number representation without radix; Computing devices using combinations of denominational and non-denominational quantity representations, e.g. using difunction pulse trains, STEELE computers, phase computers using residue arithmetic
    • G06F7/727Modulo N arithmetic, with N being either (2**n)-1,2**n or (2**n)+1, e.g. mod 3, mod 4 or mod 5

Definitions

  • the present invention relates to the field of file storage, and in particular, to a file storage method, a terminal, and a computer readable storage medium.
  • the existing file storage is stored in a single directory first, and when the file stored in the directory reaches the upper limit, the files in the directory are backed up and then emptied, the file is saved after being emptied, or the system is expanded to a new one. Directory to continue storing files.
  • This kind of file storage method requires a certain directory storage file to be specified in advance. When reading the file later, it is also necessary to remember which files are stored in that directory in order to read the file. Obviously, the file storage method is relatively rigid. Moreover, storing multiple files in the same directory for a period of time, and not storing files in another directory, will result in an unbalanced directory storage file.
  • the main purpose of the present invention is to provide a file storage method, a terminal, and a computer readable storage medium, which are aimed at solving the existing file storage method, the file storage method is relatively rigid, and the technical problem of the directory storage file being unbalanced is easily caused.
  • the present invention provides a file storage method, and the file storage method includes:
  • the feature values are modulo to obtain a modulus value, wherein the mode is obtained by dividing the total number of file directories by the feature value;
  • the present invention also provides a terminal, the terminal comprising a memory, a processor, and a file storage program stored on the memory and operable on the processor, the file storage program being The processor, when executed, implements the steps of the file storage method as described above.
  • the present invention also provides a computer readable storage medium having a file storage program stored thereon, the file storage program being executed by a processor to implement a file as described above The steps of the storage method.
  • the technical solution proposed by the present invention first determines a file name corresponding to the file to be stored when receiving the file storage instruction, and then performs feature calculation on the determined file name to obtain a feature value, and then uses the total number of file directories to The feature value is modulo, to obtain a modulus value, and the sequence number corresponding to the file name is determined based on the modulus value, and then the directory corresponding to the sequence number is determined based on the mapping relationship between the sequence number and the directory, and finally the file is stored in the determined directory. .
  • the file name is different according to the file name.
  • the file name can be stored in the corresponding directory according to the serial number corresponding to the file name. Since the storage directory is not required to be specified, the file storage method is flexible.
  • the file storage is implemented by storing the serial number corresponding to the file name in the corresponding directory, instead of storing all the files in the same directory, so that the use of each directory is more balanced.
  • FIG. 1 is a schematic structural diagram of a terminal in a hardware operating environment according to an embodiment of the present invention
  • FIG. 2 is a schematic flow chart of a first embodiment of a file storage method according to the present invention.
  • step S20 in FIG. 2 is a schematic diagram of a first refinement process of step S20 in FIG. 2;
  • step S20 in FIG. 2 is a schematic diagram of a second refinement process of step S20 in FIG. 2;
  • FIG. 5 is a schematic flowchart diagram of a second embodiment of a file storage method according to the present invention.
  • FIG. 6 is a schematic diagram of the refinement process of step S60 in FIG. 5.
  • the solution of the embodiment of the present invention is mainly: when receiving the file storage instruction, first determining the file name corresponding to the file to be stored, and then performing feature calculation on the determined file name to obtain the feature value, and then adopting the total number of file directories. And modulating the feature value to obtain a modulus value, determining a sequence number corresponding to the file name based on the modulus value, and determining a directory corresponding to the sequence number based on a mapping relationship between the sequence number and the directory, and finally storing the file to determine In the directory.
  • the flexibility is poor, and the problem of uneven use of the directory is easily caused.
  • FIG. 1 is a schematic structural diagram of a terminal in a hardware operating environment according to an embodiment of the present invention.
  • the device in the embodiment of the present invention may be a PC, or may be a mobile terminal device having a display function, such as a smart phone, a tablet computer, an e-book reader, and a portable computer.
  • the device may include a processor 1001, such as a CPU, a communication bus 1002, a user interface 1003, a network interface 1004, and a memory 1005.
  • the communication bus 1002 is used to implement connection communication between these components.
  • the user interface 1003 can include a display, an input unit such as a keyboard, and the optional user interface 1003 can also include a standard wired interface, a wireless interface.
  • the network interface 1004 can optionally include a standard wired interface, a wireless interface (such as a WI-FI interface).
  • the memory 1005 may be a high speed RAM memory or a stable memory (non-volatile) Memory), such as disk storage.
  • the memory 1005 can also optionally be a storage device independent of the aforementioned processor 1001.
  • the device may also include a camera, RF (Radio) Frequency, RF) circuits, sensors, audio circuits, WiFi modules, and more.
  • RF Radio
  • RF Radio Frequency
  • terminal structure shown in FIG. 1 does not constitute a limitation to the terminal, and may include more or less components than those illustrated, or a combination of certain components, or different component arrangements.
  • an operating system a network communication module, a user interface module, and a file storage program may be included in the memory 1005 as a computer readable storage medium.
  • the operating system is a program for managing and controlling terminal and software resources, and supports operation of a network communication module, a user interface module, a file storage program, and other programs or software; the network communication module is used to manage and control the network interface 1002; the user interface module Used to manage and control the user interface 1003.
  • the network interface 1004 is mainly used to connect to a server or an external device, and performs data communication with a server or an external device; the user interface 1003 is mainly used to connect to the terminal interface; and the terminal calls the memory 1005 through the processor 1001. Store the stored file in a program to implement the following steps:
  • the feature values are modulo to obtain a modulus value, wherein the mode is obtained by dividing the total number of file directories by the feature value;
  • the terminal calls the file storage program stored in the memory 1005 by the processor 1001 to implement feature calculation on the determined file name to obtain the feature value:
  • the binary value is mapped to a fixed length binary value by a preset hash function, and the fixed length binary value is taken as a feature value.
  • the terminal calls the file storage program stored in the memory 1005 by the processor 1001 to implement feature calculation on the determined file name to obtain the feature value:
  • the terminal calls the memory 1005 to be stored by the processor 1001.
  • the file storage program to implement the following steps:
  • the terminal calls the file storage program stored in the memory 1005 by the processor 1001, so as to determine, when receiving the file read instruction, the file to be read based on the file name carried in the file read instruction.
  • the feature values corresponding to the file names are modulo according to the total number of file directories to determine the directory where the files to be read are located.
  • the terminal is called to be stored in the memory 1005 by the processor 1001 after receiving the file read instruction.
  • the file storage program to implement the following steps:
  • the eigenvalue corresponding to the file name of the read file is modulo according to the total number of directories before the change to obtain a file directory;
  • the terminal calls the file storage program stored in the memory 1005 by the processor 1001 to implement the following steps:
  • the terminal calls the file storage program stored in the memory 1005 by the processor 1001 to implement the following steps:
  • the technical solution proposed by the embodiment when receiving the file storage instruction, first determines the file name corresponding to the file to be stored, and then performs feature calculation on the determined file name to obtain the feature value, and then uses the total number of file directories. Determining the eigenvalues to obtain a modulo value, determining a sequence number corresponding to the file name based on the modulo value, and determining a directory corresponding to the sequence number based on a mapping relationship between the sequence number and the directory, and finally storing the file in the determined directory in.
  • the file name is different according to the file name.
  • the file name can be stored in the corresponding directory according to the serial number corresponding to the file name.
  • the file storage method is flexible.
  • the file storage is implemented by storing the serial number corresponding to the file name in the corresponding directory, instead of storing all the files in the same directory, so that the use of each directory is more balanced.
  • FIG. 2 is a schematic flowchart diagram of a first embodiment of a file storage method according to the present invention.
  • the file storage method includes:
  • Step S10 when receiving the file storage instruction, determining a file name corresponding to the file to be stored
  • Step S20 performing feature calculation on the determined file name to obtain a feature value
  • Step S30 modulo the feature value by using the total number of file directories to obtain a modulus value, where the mode is obtained by dividing the total number of file directories by the feature value;
  • Step S40 determining a sequence number corresponding to the file name based on the modulus value
  • Step S50 Determine, according to a mapping relationship between the preset serial number and the directory, a directory corresponding to the serial number, and store the file in the determined directory.
  • the file storage method is applied to a terminal, and the terminal is a terminal as shown in FIG. 1.
  • the terminal is provided with one or more directories for storing files.
  • Step S10 when receiving a file storage instruction, determining a file name corresponding to the file to be stored, wherein the file name includes a Chinese character, a letter or a number;
  • the receiving manner of the file storage instruction includes:
  • the display selection interface is configured to receive a file storage instruction triggered by the user on the selection interface.
  • the display selection interface is configured to receive a file storage instruction triggered by the user on the selection interface.
  • the file to be stored corresponding to the file storage instruction is first determined.
  • the file storage instruction is triggered, it is triggered for a specific file, so the corresponding file to be stored may be determined according to the file storage instruction. .
  • the file name of the file to be stored is identified.
  • the file name includes, but is not limited to, a Chinese character, a letter, a number, a symbol, or a combination of two or more of the foregoing.
  • the file name of the file to be stored in this embodiment may be the name of the file before the terminal receives the file. That is, before the external device imports the file to the terminal, or before the server transfers the file to the terminal, the file has been added with the file name, and after the subsequent terminal receives the file, the file name corresponding to the file is directly recognized.
  • the file name when the terminal receives the file or the local end generated file, the file name may be regenerated for each file according to a preset rule, and the preset rule may be set to: add a file name to the file according to the letter.
  • the added file names are added in alphabetical order, for example, first adding the letter a to the first file, then adding the letter b to the second file, and so on, adding corresponding letters to each file to achieve The addition of the file name. After adding a file name to a file, you can determine the file name for each file.
  • the terminal in order to facilitate the management of the file storage, the terminal preferably regenerates the corresponding file name according to the preset rule of the terminal system when receiving the file, and then, according to the file name, the serial number of each file can be quickly determined according to the file name.
  • the present invention can be processed in the same manner, thereby improving the efficiency of file storage.
  • Step S20 performing feature calculation on the determined file name to obtain a feature value
  • the implementation manner of the step S20 includes:
  • Step S20 includes:
  • Step S21 querying a binary value corresponding to the file name based on the pre-stored binary comparison table
  • Step S22 mapping the binary value into a fixed-length binary value by using a preset hash function, and using the fixed-length binary value as the feature value.
  • the ASCII table stores Chinese characters, letters, or The correspondence between numbers and binary values.
  • each binary value is not fixed, because the file names of different files are different, so the length of each binary value obtained by looking up the table may be different.
  • the binary values of the respective file names are hashed, and the hash calculation is performed by: mapping the binary values of arbitrary length to a smaller binary value of a fixed length by using a hash function. For example, if the binary value of the file name is 11050201, then after hash mapping by function, 778 is obtained, and this small binary value is called a hash value. In this way, the hash calculation of the file name can be implemented, and the hash function is set according to the actual situation, which is not limited herein.
  • Step S20 includes:
  • Step S23 acquiring a pre-stored coding table
  • Step S24 Acquire an encoding value corresponding to the file name based on a correspondence between the file name and the encoded value in the pre-stored encoding table, and use the obtained encoded value as the feature value.
  • the file name may be encoded and mapped.
  • the preset encoding table is first queried to determine the encoded value corresponding to the file name according to the encoding table.
  • the coding table is a pre-established table, and includes correspondences between various letters, Chinese characters, numbers, or symbols and code values. Therefore, after the file name is identified, the code value can be determined by querying the code table. For example, the file name of the file is the letter T. By checking the code table, the corresponding code value is 6.
  • the hash value and the encoded value are equivalent to the feature value, and the hash value and the encoded value may be moduloized later to obtain the corresponding modulus value.
  • Step S30 modulo the feature value by using the total number of file directories to obtain a modulus value, where the mode is obtained by dividing the total number of file directories by the feature value;
  • the feature value before modulating the feature values, first determine the total number of current file directories in the terminal, and then modulo the feature values of the file names according to the total number of file directories to obtain a modulus value, specifically, the file The total number of directories divided by the feature value. Since the feature value includes a hash value and an encoded value, dividing the total number of file directories by the feature value is equivalent to dividing the total number of file directories by the hash value of the file name or The encoded value is the modulus of the file name after the file directory is divided by the hash value or the encoded value.
  • the current total number of file directories is 7. If the hash value or encoding value of the file is 2, then the total number of file directories 7 is divided by 2, and the remainder is 1, to determine the modulus value of the file name is 1; The hash value of the current file is 4, and the total number of file directories 7 is divided by 4, and the remainder is 3, and the modulus value of the file name is determined to be 3.
  • Step S40 Determine a sequence number corresponding to the file name based on the modulus value.
  • the sequence number corresponding to the file name is 1, if the modulus value after the feature calculation If it is 3, the serial number corresponding to the file name is 3.
  • Step S50 Determine, according to a mapping relationship between the preset serial number and the directory, a directory corresponding to the serial number, and store the file in the determined directory.
  • the mapping relationship between the sequence number and the directory is further determined.
  • the mapping relationship is preferably a one-to-one relationship, that is, one serial number corresponds to one directory, and therefore, the file is determined.
  • the directory to be stored in the file can be determined, and finally the file is stored in the determined directory.
  • the technical solution proposed by the embodiment when receiving the file storage instruction, first determines the file name corresponding to the file to be stored, and then performs feature calculation on the determined file name to obtain the feature value, and then uses the total number of file directories. Determining the eigenvalues to obtain a modulo value, determining a sequence number corresponding to the file name based on the modulo value, and determining a directory corresponding to the sequence number based on a mapping relationship between the sequence number and the directory, and finally storing the file in the determined directory in.
  • the file name is different according to the file name.
  • the file name can be stored in the corresponding directory according to the serial number corresponding to the file name.
  • the file storage method is flexible.
  • the file storage is implemented by storing the serial number corresponding to the file name in the corresponding directory, instead of storing all the files in the same directory, so that the use of each directory is more balanced.
  • the second embodiment of the file storage method differs from the first embodiment of the file storage method in that, after referring to FIG. 5, after the step S50, the method further includes:
  • Step S60 when receiving the file reading instruction, determining, according to the file name carried in the file reading instruction, a directory in which the file to be read is located;
  • Step S70 reading the file in the determined directory.
  • the receiving manner of the file reading instruction includes:
  • the terminal receives a file reading instruction triggered by the user input file name in a preset search interface
  • the terminal receives the file input instruction triggered by the user voice input file name.
  • the terminal determines the directory in which the file to be read is located based on the file name carried in the file reading instruction. Specifically, referring to FIG. 6, the step S60 includes:
  • Step S61 determining a file name carried in the file reading instruction
  • Step S62 performing feature calculation on the file name to obtain a feature value
  • Step S63 modulating the feature value corresponding to the file name according to the total number of file directories to determine a directory where the file to be read is located.
  • the terminal when receiving the file read instruction, determines the file name to be read based on the file read instruction, and then modulo the file name by using the total number of file directories to obtain the file to be read.
  • a directory specifically: performing feature calculation on the file name to obtain a feature value, and then using the total number of file directories to modulate the feature value to obtain a modulus value, where the modulus value is a sequence number corresponding to the file name, and finally
  • the directory in which the file to be read is located can be determined according to the serial number.
  • the directory of the file is obtained according to the eigenvalue modulo, so that the file can be obtained in the correct directory, and it is not necessary to remember which file exists in which directory, which is transparent to the upper application, and is improved.
  • the convenience and intelligence of file storage is improved.
  • the third embodiment of the file storage method differs from the second embodiment of the file storage method in that after the step S60, the method further includes:
  • Step A When the file is not read in the determined directory, the total number of directories before the change is queried;
  • Step B modulo the feature value corresponding to the file name of the read file according to the total number of directories before the change, to obtain a file directory;
  • Step C reading the file in the file directory.
  • the directory where the file is located is obtained, if the file corresponding to the file name is not read in the directory, the file name is not stored in the file.
  • the directory the number of directories in the terminal has been changed. That is, when the file is stored before, the number of the file name is determined by the total number of directories before the change. Therefore, the directory is the directory corresponding to the previous serial number. Now, the file name is determined by the total number of changed directories. The serial number, so the calculated directory is different from before, so the stored file cannot be found.
  • the way the directory is changed includes: increasing the directory or reducing the number of directories.
  • the terminal when the file is not read in the determined directory, the terminal queries the total number of directories before the change from the backup document, that is, the terminal saves the specific number of the file directory, and even if the change occurs, the terminal can perform the change.
  • Query after querying the total number of directories before the change, and then modulo the file name of the read file according to the total number of directories before the change, to obtain the file directory, and finally read the file in the file directory, and the specific processing manner is also It has been described in detail in the above embodiments, and details are not described herein again.
  • the corresponding directory is used to determine the directory where the file is located, and the upper layer application does not need to modify the file name, thereby improving the convenience and intelligence of file storage.
  • a fourth embodiment of the file storage method of the present invention is proposed based on the first to third embodiments.
  • Step D When it is detected that the storage capacity of the directory reaches the preset capacity value, if the expansion instruction of the directory is received, determine the number of directories to be expanded;
  • step E a certain number of directories are added to the system.
  • the file directory in the terminal may be one or multiple, and is not limited, and is set according to actual conditions.
  • the terminal When the terminal detects that the storage capacity in the existing directory reaches the preset capacity value, the terminal may output a prompt message to indicate that the directory is overloaded. At this time, if the extension instruction of the directory is received, a selection window is displayed for the user to input the number of directories to be filled, and finally the directory corresponding to the number is added in the terminal, and the preset capacity value and the to-be-charged
  • the number of directories is not limited.
  • the newly added directory is sorted based on the existing existing directory, and the mapping relationship table corresponding to the serial number and the directory is updated to add the serial number corresponding to the newly added directory in the relationship mapping table.
  • the total number of directories of the terminal also changes accordingly, so that the storage and reading of the file are more accurate when the subsequent features are processed.
  • the method further includes:
  • step F when it is detected that the storage capacity of the directory reaches the preset capacity value, if the directory clear command is received, the file of the directory is backed up to the preset storage area;
  • step G after the file backup is completed, the directory is emptied.
  • the existing file in the directory is directly backed up to the preset storage area without adding a new directory.
  • the directory is then emptied so that the file continues to be stored according to the directory.
  • the processing is performed by the foregoing two methods, so as to continue to store the file subsequently, and the file storage flexibility is improved.
  • an embodiment of the present invention further provides a computer readable storage medium, where the file storage program is stored on the computer readable storage medium, and when the file storage program is executed by the processor, the following operations are implemented:
  • the feature values are modulo to obtain a modulus value, wherein the mode is obtained by dividing the total number of file directories by the feature value;
  • the binary value is mapped to a fixed length binary value by a preset hash function, and the fixed length binary value is taken as a feature value.
  • the operation of determining the directory where the file to be read is determined based on the file name carried in the file read instruction when receiving the file read instruction is further implemented:
  • the feature values corresponding to the file names are modulo according to the total number of file directories to determine the directory where the files to be read are located.
  • the eigenvalue corresponding to the file name of the read file is modulo according to the total number of directories before the change to obtain a file directory;
  • the technical solution proposed by the embodiment when receiving the file storage instruction, first determines the file name corresponding to the file to be stored, and then performs feature calculation on the determined file name to obtain the feature value, and then uses the total number of file directories. Determining the eigenvalues to obtain a modulo value, determining a sequence number corresponding to the file name based on the modulo value, and determining a directory corresponding to the sequence number based on a mapping relationship between the sequence number and the directory, and finally storing the file in the determined directory in.
  • the file name is different according to the file name.
  • the file name can be stored in the corresponding directory according to the serial number corresponding to the file name.
  • the file storage method is flexible.
  • the file storage is implemented by storing the serial number corresponding to the file name in the corresponding directory, instead of storing all the files in the same directory, so that the use of each directory is more balanced.
  • the foregoing embodiment method can be implemented by means of software plus a necessary general hardware platform, and of course, can also be through hardware, but in many cases, the former is better.
  • Implementation Based on such understanding, the technical solution of the present invention, which is essential or contributes to the prior art, may be embodied in the form of a software product stored in a storage medium (such as ROM/RAM, disk,
  • the optical disc includes a number of instructions for causing a terminal device (which may be a cell phone, a computer, a server, an air conditioner, or a network device, etc.) to perform the methods described in various embodiments of the present invention.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Databases & Information Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Data Mining & Analysis (AREA)
  • Mathematical Physics (AREA)
  • Human Computer Interaction (AREA)
  • Mathematical Analysis (AREA)
  • Computational Mathematics (AREA)
  • Mathematical Optimization (AREA)
  • Pure & Applied Mathematics (AREA)
  • Library & Information Science (AREA)
  • Software Systems (AREA)
  • Computing Systems (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

本发明公开了一种文件存储方法,所述方法包括:在接收到文件存储指令时,确定待存储的文件对应的文件名;对确定的文件名进行特征计算,以得到特征值;采用文件目录的总数对所述特征值取模,以得到模值,其中,取模的方式为:采用文件目录的总数除以所述特征值;基于所述模值确定所述文件名对应的序号;基于预设序号与目录的映射关系,确定所述序号对应的目录,并将所述文件存储到确定的目录中。本发明还公开了一种终端和计算机可读存储介质。本发明不仅提高了文件存储的的灵活性,还使得各个目录的使用更加均衡。

Description

文件存储方法、终端和计算机可读存储介质
本申请要求于2017年07月27日提交中国专利局、申请号为201710622747.4、发明名称为“文件存储方法、终端和计算机可读存储介质”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本发明涉及文件存储领域,尤其涉及一种文件存储方法、终端和计算机可读存储介质。
背景技术
现有的文件存储,是先在单个目录下进行存储,并在目录中存储的文件达到上限时,将目录中的文件备份后进行清空,以清空后继续存储文件,或者系统再扩容一个新的目录以继续存储文件。
这种文件存储方式,都需要事先指定某个目录存储文件,后续读取文件时,也需要记住哪些文件存储在那个目录下,才能读取到文件,显然,文件存储的方式较为死板。并且,一段时间内在同一个目录下存储多个文件,另一个目录不存文件,会导致目录存储文件不均衡。
发明内容
本发明的主要目的在于提供一种文件存储方法、终端和计算机可读存储介质,旨在解决现有的文件存储方式,文件存储方式较为死板,并且容易导致目录存储文件不均衡的技术问题。
为实现上述目的,本发明提供一种文件存储方法,所述文件存储方法包括:
在接收到文件存储指令时,确定待存储的文件对应的文件名;
对确定的文件名进行特征计算,以得到特征值;
采用文件目录的总数对所述特征值取模,以得到模值,其中,取模的方式为:采用文件目录的总数除以所述特征值;
基于所述模值确定所述文件名对应的序号;
基于预设序号与目录的映射关系,确定所述序号对应的目录,并将所述文件存储到确定的目录中。
此外,为实现上述目的,本发明还提供一种终端,所述终端包括存储器、处理器及存储在所述存储器上并可在所述处理器上运行的文件存储程序,所述文件存储程序被所述处理器执行时实现如上文所述的文件存储方法的步骤。
此外,为实现上述目的,本发明还提供一种计算机可读存储介质,所述计算机可读存储介质上存储有文件存储程序,所述文件存储程序被处理器执行时实现如上文所述的文件存储方法的步骤。
本发明提出的技术方案,在接收到文件存储指令时,先确定待存储的文件对应的文件名,然后对确定的文件名进行特征计算,以得到特征值,再采用文件目录的总数对所述特征值取模,以得到模值,基于所述模值确定所述文件名对应的序号,再基于序号与目录的映射关系,确定所述序号对应的目录,最终将文件存储到确定的目录中。本发明由于文件名不同,文件名最终对应的序号也不同,最终可根据按照文件名对应的序号,将文件存储到相应的目录下,由于不需要指定存储目录,使得文件存储的方式较为灵活。此外,实现了文件存储,是按照文件名对应的序号存储至相应的目录中,而不是将所有文件都存储至同一个目录下,使得各个目录的使用更加均衡。
附图说明
图1是本发明实施例方案涉及的硬件运行环境的终端结构示意图;
图2为本发明文件存储方法第一实施例的流程示意图;
图3为图2中步骤S20的第一细化流程示意图;
图4为图2中步骤S20的第二细化流程示意图;
图5为本发明文件存储方法第二实施例的流程示意图;
图6为图5中步骤S60的细化流程示意图。
本发明目的的实现、功能特点及优点将结合实施例,参照附图做进一步说明。
具体实施方式
应当理解,此处所描述的具体实施例仅仅用以解释本发明,并不用于限定本发明。
本发明实施例的解决方案主要是:在接收到文件存储指令时,先确定待存储的文件对应的文件名,然后对确定的文件名进行特征计算,以得到特征值,再采用文件目录的总数对所述特征值取模,以得到模值,基于所述模值确定所述文件名对应的序号,再基于序号与目录的映射关系,确定所述序号对应的目录,最终将文件存储到确定的目录中。以解决现有的文件存储方式,灵活性差,且容易导致目录使用不均衡的问题。
如图1所示,图1是本发明实施例方案涉及的硬件运行环境的终端结构示意图。
本发明实施例设备可以是PC,也可以是智能手机、平板电脑、电子书阅读器、便携计算机等具有显示功能的可移动式终端设备。
如图1所示,该设备可以包括:处理器1001,例如CPU,通信总线1002、用户接口1003,网络接口1004,存储器1005。其中,通信总线1002用于实现这些组件之间的连接通信。用户接口1003可以包括显示屏(Display)、输入单元比如键盘(Keyboard),可选用户接口1003还可以包括标准的有线接口、无线接口。网络接口1004可选的可以包括标准的有线接口、无线接口(如WI-FI接口)。存储器1005可以是高速RAM存储器,也可以是稳定的存储器(non-volatile memory),例如磁盘存储器。存储器1005可选的还可以是独立于前述处理器1001的存储装置。
可选地,设备还可以包括摄像头、RF(Radio Frequency,射频)电路,传感器、音频电路、WiFi模块等等。
本领域技术人员可以理解,图1中示出的终端结构并不构成对终端的限定,可以包括比图示更多或更少的部件,或者组合某些部件,或者不同的部件布置。
如图1所示,作为一种计算机可读存储介质的存储器1005中可以包括操作系统、网络通信模块、用户接口模块以及文件存储程序。其中,操作系统是管理和控制终端与软件资源的程序,支持网络通信模块、用户接口模块、文件存储程序以及其他程序或软件的运行;网络通信模块用于管理和控制网络接口1002;用户接口模块用于管理和控制用户接口1003。
在图1所示的终端中,网络接口1004主要用于连接服务器或外接设备,与服务器或外接设备进行数据通信;用户接口1003主要用于连接终端界面;所述终端通过处理器1001调用存储器1005中存储的文件存储程序,以实现以下步骤:
在接收到文件存储指令时,确定待存储的文件对应的文件名;
对确定的文件名进行特征计算,以得到特征值;
采用文件目录的总数对所述特征值取模,以得到模值,其中,取模的方式为:采用文件目录的总数除以所述特征值;
基于所述模值确定所述文件名对应的序号;
基于预设序号与目录的映射关系,确定所述序号对应的目录,并将所述文件存储到确定的目录中。
进一步地,所述终端通过处理器1001调用存储器1005中存储的文件存储程序,以实现对确定的文件名进行特征计算,以得到特征值的步骤:
基于预存的二进制对照表,查询文件名对应的二进制值;
通过预设的哈希函数将所述二进制值映射成固定长度的二进制值,将所述固定长度的二进制值作为特征值。
进一步地,所述终端通过处理器1001调用存储器1005中存储的文件存储程序,以实现对确定的文件名进行特征计算,以得到特征值的步骤:
获取预存编码表;
基于预存编码表中文件名与编码值的对应关系,获取所述文件名对应的编码值,将获取的所述编码值作为特征值。
进一步地,所述基于预设序号与目录的映射关系,确定所述序号对应的目录,并将所述文件存储到确定的目录中的步骤之后,所述终端通过处理器1001调用存储器1005中存储的文件存储程序,以实现以下步骤:
在接收到文件读取指令时,基于所述文件读取指令中携带的文件名确定待读取文件所在的目录;
在确定的目录中读取文件。
进一步地,所述终端通过处理器1001调用存储器1005中存储的文件存储程序,以实现在接收到文件读取指令时,基于所述文件读取指令中携带的文件名确定待读取文件所在的目录的步骤:
确定所述文件读取指令中携带的文件名;
对文件名进行特征计算,以得到特征值;
根据文件目录的总数对所述文件名对应的特征值取模,以确定待读取文件所在的目录。
进一步地,所述在接收到文件读取指令时,基于所述文件读取指令中携带的文件名确定待读取文件所在的目录的步骤之后,所述终端通过处理器1001调用存储器1005中存储的文件存储程序,以实现以下步骤:
在确定的目录中读取不到文件时,查询变更前的目录总数;
根据变更前的目录总数对待读取文件的文件名对应的特征值取模,以得到文件目录;
在所述文件目录中读取文件。
进一步地,所述终端通过处理器1001调用存储器1005中存储的文件存储程序,以实现以下步骤:
在检测到目录的存储容量达到预设容量值时,若接收到目录的扩充指令,确定待扩充目录的个数;
在系统中新增确定个数的目录。
进一步地,所述终端通过处理器1001调用存储器1005中存储的文件存储程序,以实现以下步骤:
在检测到目录的存储容量达到预设容量值时,若接收到目录的清空指令,将目录的文件备份至预设存储区中;
在文件备份完成后,清空所述目录。
本实施例提出的技术方案,在接收到文件存储指令时,先确定待存储的文件对应的文件名,然后对确定的文件名进行特征计算,以得到特征值,再采用文件目录的总数对所述特征值取模,以得到模值,基于所述模值确定所述文件名对应的序号,再基于序号与目录的映射关系,确定所述序号对应的目录,最终将文件存储到确定的目录中。本发明由于文件名不同,文件名最终对应的序号也不同,最终可根据按照文件名对应的序号,将文件存储到相应的目录下,由于不需要指定存储目录,使得文件存储的方式较为灵活。此外,实现了文件存储,是按照文件名对应的序号存储至相应的目录中,而不是将所有文件都存储至同一个目录下,使得各个目录的使用更加均衡。
基于上述终端硬件结构,提出本发明文件存储方法的各个实施例。
参照图2,图2为本发明文件存储方法第一实施例的流程示意图。
在本实施例中,所述文件存储方法包括:
步骤S10,在接收到文件存储指令时,确定待存储的文件对应的文件名;
步骤S20,对确定的文件名进行特征计算,以得到特征值;
步骤S30,采用文件目录的总数对所述特征值取模,以得到模值,其中,取模的方式为:采用文件目录的总数除以所述特征值;
步骤S40,基于所述模值确定所述文件名对应的序号;
步骤S50,基于预设序号与目录的映射关系,确定所述序号对应的目录,并将所述文件存储到确定的目录中。
在本实施例中,所述文件存储方法应用于终端,所述终端如图1所示的终端。所述终端设置有一个或多个目录,目录用于存储文件。
以下是本实施例中实现文件存储的具体步骤:
步骤S10,在接收到文件存储指令时,确定待存储的文件对应的文件名,其中,所述文件名包括汉字、字母或数字;
在本实施例中,所述文件存储指令的接收方式包括:
a、终端接收到外接设备导入的文件时,显示选择界面,以接收用户在所述选择界面触发的文件存储指令。
b、终端接收到服务器传输的文件时,显示选择界面,以接收用户在所述选择界面触发的文件存储指令。
c、终端接收本端数据信息生成文件时触发的文件存储指令。
在接收到文件存储指令时,先确定所述文件存储指令对应的待存储文件,由于确定触发该文件存储指令时,是针对具体的文件触发的,因此根据文件存储指令可确定对应的待存储文件。
在确定待存储文件指令之后,再识别该待存储文件的文件名,本实施例中,所述文件名包括但不限于汉字、字母、数字、符号或上述任两项或多项的组合。
需要说明的是,本实施例中待存储文件的文件名,可以是终端接收到文件之前,该文件自带的名称。即在外接设备导入文件到终端之前,或者是服务器传输文件到终端之前,文件已经添加有文件名,后续终端接收到文件之后,直接识别该文件对应的文件名即可。
此外,本发明实施例,还可以在终端接收到文件或本端生成文件时,根据预设规则为每一个文件重新生成文件名,所述预设规则可设置为:根据字母对文件添加文件名,并且添加的文件名是按照字母的顺序进行添加,例如,先对第一个文件添加字母a,后续对第二个文件添加字母b,以此类推,为各个文件添加相应的字母,以实现文件名的添加。对文件添加文件名之后,即可确定各个文件对应的文件名。
应当理解,上述的预设规则仅仅是示例性,本领域技术人员,根据本发明的技术思想所提出的其它规则均在本发明的保护范围内,此处不再一一赘述。
本实施例中,为了便于文件存储的管理,优选终端在接收到文件时,根据终端系统自带的预设规则重新生成对应的文件名,后续,即可根据文件名,快速确定各个文件的序号,以便于快速进行文件的存储,而不用对不同类型的文件名分别进行处理以得到序号,本发明可以按照同一个种方式进行处理,提高了文件存储的效率。
步骤S20,对确定的文件名进行特征计算,以得到特征值;
在本实施例中,所述步骤S20的实施方式包括:
1)方式一、参照图3,所述步骤S20包括:
步骤S21,基于预存的二进制对照表,查询文件名对应的二进制值;
步骤S22,通过预设的哈希函数将所述二进制值映射成固定长度的二进制值,将所述固定长度的二进制值作为特征值。
在本实施方式中,在确定文件对应的文件名之后,查阅预设的二进制对照表,如ASCII表,以确定文件名对应的二进制值,本实施例中,该ASCII表存储有汉字、字母或数字与二进制值的对应关系。
需要说明的是,各个二进制值的长度不是固定的,因为不同文件的文件名不同,因此通过查表得到的各个二进制值的长度可能不同。
在确定各个文件的二进制值之后,再对各个文件名的二进制值进行哈希计算,所述哈希计算的方式为:通过哈希函数将任意长度的二进制值映射为固定长度的较小二进制值,例如,文件名的二进制值为11050201,那么通过函数进行哈希映射后,得到778,这个小的二进制值称为哈希值。通过这种方式,即可实现对文件名的哈希计算,所述哈希函数根据实际情况设置,此处不做限定。
2)方式二、参照图4,所述步骤S20包括:
步骤S23,获取预存编码表;
步骤S24,基于预存编码表中文件名与编码值的对应关系,获取所述文件名对应的编码值,将获取的所述编码值作为特征值。
在本实施方式中,确定文件对应的文件名之后,还可对文件名进行编码映射,具体地,先查询预设的编码表,以根据该编码表,确定文件名对应的编码值。需要说明的是,该编码表是事先建立的表,包含各种字母、汉字、数字或符号与编码值的对应关系。因此,在识别出文件名之后,通过查询该编码表,即可确定编码值,例如,文件的文件名为字母T,通过查该编码表,得出对应的编码值为6。
在根据文件名得到对应的哈希值或者编码值之后,该哈希值和编码值相当于是特征值,后续即可对哈希值和编码值进行取模,以得到相应的模值。
步骤S30,采用文件目录的总数对所述特征值取模,以得到模值,其中,取模的方式为:采用文件目录的总数除以所述特征值;
在本实施例中,在对特征值取模之前,先确定终端中当前文件目录的总数,然后根据文件目录的总数,对文件名的特征值取模,以得到模值,具体的,将文件目录的总数除以所述特征值,由于特征值包括哈希值和编码值,因此,将文件目录的总数除以所述特征值,相当于是文件目录的总数除以文件名的哈希值或编码值,在文件目录除以哈希值或编码值之后,将得到的余数作为文件名的模值。
为更好理解,举例如下:
当前的文件目录总数为7,若文件的哈希值或编码值为2,那么,将文件目录总数7除以2,可得到余数为1,即可确定该文件名的模值为1;若当前文件的哈希值为4,将文件目录总数7除以4,可得到余数为3,即可确定该文件名的模值为3。
步骤S40,基于所述模值确定所述文件名对应的序号。
在计算得到文件名的模值之后,基于所述模值确定文件名对应的序号,例如特征计算后的模值为1,那么该文件名对应的序号就是为1,若特征计算后的模值为3,那么该文件名对应的序号就为3。
步骤S50,基于预设序号与目录的映射关系,确定所述序号对应的目录,并将所述文件存储到确定的目录中。
在确定各个文件名对应的序号之后,再进一步地确定序号和目录的映射关系,本实施例中,所述映射关系优选是1对1的关系,即一个序号对应一个目录,因此,在确定文件名对应的序号之后,即可确定文件待存储的目录,最终将文件存储到确定的目录中。
本实施例提出的技术方案,在接收到文件存储指令时,先确定待存储的文件对应的文件名,然后对确定的文件名进行特征计算,以得到特征值,再采用文件目录的总数对所述特征值取模,以得到模值,基于所述模值确定所述文件名对应的序号,再基于序号与目录的映射关系,确定所述序号对应的目录,最终将文件存储到确定的目录中。本发明由于文件名不同,文件名最终对应的序号也不同,最终可根据按照文件名对应的序号,将文件存储到相应的目录下,由于不需要指定存储目录,使得文件存储的方式较为灵活。此外,实现了文件存储,是按照文件名对应的序号存储至相应的目录中,而不是将所有文件都存储至同一个目录下,使得各个目录的使用更加均衡。
进一步地,基于第一实施例提出本发明文件存储方法的第二实施例。
文件存储方法的第二实施例与文件存储方法的第一实施例的区别在于,参照图5,所述步骤S50之后,所述方法还包括:
步骤S60,在接收到文件读取指令时,基于所述文件读取指令中携带的文件名确定待读取文件所在的目录;
步骤S70,在确定的目录中读取文件。
在本实施例中,所述文件读取指令的接收方式包括:
d、终端在预设的搜索界面中,接收用户输入文件名所触发的文件读取指令;
e、终端接收用户语音输入文件名以触发的文件读取指令。
在接收到文件读取指令时,所述终端基于所述文件读取指令中携带的文件名确定待读取文件所在的目录,具体地,参照图6,所述步骤S60包括:
步骤S61,确定所述文件读取指令中携带的文件名;
步骤S62,对文件名进行特征计算,以得到特征值;
步骤S63,根据文件目录的总数对所述文件名对应的特征值取模,以确定待读取文件所在的目录。
即,终端在接收到文件读取指令时,基于所述文件读取指令确定待读取的文件名,然后同样采用文件目录的总数对所述文件名取模,以得到确定待读取文件所在的目录,具体地:先对文件名进行特征计算以得到特征值,再采用文件目录的总数对所述特征值取模以得到模值,所述模值就为所述文件名对应的序号,最终根据序号即可确定待读取文件所在的目录,具体的处理方式在上文实施例中已经详述,此处不再赘述。
在本实施例中,同样是根据特征值取模获得该文件的目录,因此能在正确的目录下得到文件,不需要记住哪个文件存在哪个目录下,对上层应用而言是透明的,提高了文件存储的便捷性和智能性。
进一步地,基于第二实施例提出本发明文件存储方法的第三实施例。
文件存储方法的第三实施例与文件存储方法的第二实施例的区别在于,所述步骤S60之后,所述方法还包括:
步骤A,在确定的目录中读取不到文件时,查询变更前的目录总数;
步骤B,根据变更前的目录总数对待读取文件的文件名对应的特征值取模,以得到文件目录;
步骤C,在所述文件目录中读取文件。
在本实施例中,通过上述的处理过程对文件名进行处理,并得到文件所在的目录之后,若在该目录下读取不到该文件名对应的文件,说明该文件名并没有存储在该目录下,说明终端的目录数量发生过变更,即之前存储文件时,是采用变更前的目录总数确定文件名的序号,因此目录是之前序号对应的目录,现在采用变更后的目录总数确定文件名的序号,因此计算出的目录与之前不同,因此就无法找到存储的文件,其中,目录变更的方式包括:增加目录或减少目录数量。
因此,本实施例中,在确定的目录中读取不到文件时,终端从备份文档中,查询出变更前的目录总数,即终端会保存文件目录的具体数量,即使发生变更,也可以进行查询,在查询到变更前的目录总数之后,再根据变更前的目录总数对待读取文件的文件名取模,以得到文件目录,最终在所述文件目录中读取文件,具体的处理方式同样在上文实施例中已经详述,此处不再赘述。
在本实施例中读取文件时,在目录数变更时,采用相应的目录总数确定文件所在的目录即可,上层应用也不需要修改文件名,提高了文件存储的便捷性和智能性。
进一步地,基于第一至第三实施例提出本发明文件存储方法的第四实施例。
文件存储方法的第四实施例与文件存储方法的第一至第三实施例的区别在于,所述方法还包括:
步骤D,在检测到目录的存储容量达到预设容量值时,若接收到目录的扩充指令,确定待扩充目录的个数;
步骤E,在系统中新增确定个数的目录。
在本实施例中,终端中的文件目录,可以是一个,也可以是多个,具体不做限定,根据实际情况设置。
当终端检测到已有目录中的存储容量达到预设容量值时,可输出提示信息,以提示该目录已经超负荷。此时,若接收到目录的扩充指令,显示选择窗口,以供用户输入待括充的目录个数,最终在终端中新增该个数对应的目录,该预设容量值和待括充的目录个数不做限定,
在新增目录之后,在原来已有目录的基础上,对新增的目录进行排序,并更新序号和目录对应的映射关系表,以在该关系映射表中添加新增的目录对应的序号。在新增目录之后,所述终端的目录总数也要相应发生改变,以使后续特征处理时,对文件的存储和读取更加准确。
此外,所述方法还包括:
步骤F,在检测到目录的存储容量达到所述预设容量值时,若接收到目录的清空指令,将目录的文件备份至预设存储区中;
步骤G,在文件备份完成后,清空所述目录。
即,在检测到目录的存储容量达到所述预设容量值时,若接收到目录的清空指令,此时,不用新增目录,直接将目录中已有的文件备份至预设存储区中,然后再对目录进行清空,以便后续根据该目录继续存储文件。
本实施例中,在目录中的文件存储容量达到预设容量值时,通过上述两种方式进行处理,以便后续继续存储文件,提高了文件存储的灵活性。
此外,本发明实施例还提出一种计算机可读存储介质,所述计算机可读存储介质上存储有文件存储程序,所述文件存储程序被处理器执行时实现如下操作:
在接收到文件存储指令时,确定待存储的文件对应的文件名;
对确定的文件名进行特征计算,以得到特征值;
采用文件目录的总数对所述特征值取模,以得到模值,其中,取模的方式为:采用文件目录的总数除以所述特征值;
基于所述模值确定所述文件名对应的序号;
基于预设序号与目录的映射关系,确定所述序号对应的目录,并将所述文件存储到确定的目录中。
进一步地,所述文件存储程序被处理器执行时,还实现对确定的文件名进行特征计算,以得到特征值的操作:
基于预存的二进制对照表,查询文件名对应的二进制值;
通过预设的哈希函数将所述二进制值映射成固定长度的二进制值,将所述固定长度的二进制值作为特征值。
进一步地,所述文件存储程序被处理器执行时,还实现对确定的文件名进行特征计算,以得到特征值的操作:
获取预存编码表;
基于预存编码表中文件名与编码值的对应关系,获取所述文件名对应的编码值,将获取的所述编码值作为特征值。
进一步地,所述基于预设序号与目录的映射关系,确定所述序号对应的目录,并将所述文件存储到确定的目录中的步骤之后,所述文件存储程序被处理器执行时,还实现以下操作:
在接收到文件读取指令时,基于所述文件读取指令中携带的文件名确定待读取文件所在的目录;
在确定的目录中读取文件。
进一步地,所述文件存储程序被处理器执行时,还实现在接收到文件读取指令时,基于所述文件读取指令中携带的文件名确定待读取文件所在的目录的操作:
确定所述文件读取指令中携带的文件名;
对文件名进行特征计算,以得到特征值;
根据文件目录的总数对所述文件名对应的特征值取模,以确定待读取文件所在的目录。
进一步地,所述在接收到文件读取指令时,基于所述文件读取指令中携带的文件名确定待读取文件所在的目录的步骤之后,所述文件存储程序被处理器执行时,还实现以下操作:
在确定的目录中读取不到文件时,查询变更前的目录总数;
根据变更前的目录总数对待读取文件的文件名对应的特征值取模,以得到文件目录;
在所述文件目录中读取文件。
进一步地,所述文件存储程序被处理器执行时,还实现以下操作:
在检测到目录的存储容量达到预设容量值时,若接收到目录的扩充指令,确定待扩充目录的个数;
在系统中新增确定个数的目录。
进一步地,所述文件存储程序被处理器执行时,还实现以下操作:
在检测到目录的存储容量达到预设容量值时,若接收到目录的清空指令,将目录的文件备份至预设存储区中;
在文件备份完成后,清空所述目录。
本实施例提出的技术方案,在接收到文件存储指令时,先确定待存储的文件对应的文件名,然后对确定的文件名进行特征计算,以得到特征值,再采用文件目录的总数对所述特征值取模,以得到模值,基于所述模值确定所述文件名对应的序号,再基于序号与目录的映射关系,确定所述序号对应的目录,最终将文件存储到确定的目录中。本发明由于文件名不同,文件名最终对应的序号也不同,最终可根据按照文件名对应的序号,将文件存储到相应的目录下,由于不需要指定存储目录,使得文件存储的方式较为灵活。此外,实现了文件存储,是按照文件名对应的序号存储至相应的目录中,而不是将所有文件都存储至同一个目录下,使得各个目录的使用更加均衡。
需要说明的是,在本文中,术语“包括”、“包含”或者其任何其它变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、方法、物品或者装置不仅包括那些要素,而且还包括没有明确列出的其它要素,或者是还包括为这种过程、方法、物品或者装置所固有的要素。在没有更多限制的情况下,由语句“包括一个……”限定的要素,并不排除在包括该要素的过程、方法、物品或者装置中还存在另外的相同要素。
上述本发明实施例序号仅仅为了描述,不代表实施例的优劣。
通过以上的实施方式的描述,本领域的技术人员可以清楚地了解到上述实施例方法可借助软件加必需的通用硬件平台的方式来实现,当然也可以通过硬件,但很多情况下前者是更佳的实施方式。基于这样的理解,本发明的技术方案本质上或者说对现有技术做出贡献的部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质(如ROM/RAM、磁碟、光盘)中,包括若干指令用以使得一台终端设备(可以是手机,计算机,服务器,空调器,或者网络设备等)执行本发明各个实施例所述的方法。
以上仅为本发明的优选实施例,并非因此限制本发明的专利范围,凡是利用本发明说明书及附图内容所作的等效结构或等效流程变换,或直接或间接运用在其它相关的技术领域,均同理包括在本发明的专利保护范围内。

Claims (20)

  1. 一种文件存储方法,其特征在于,所述文件存储方法包括:
    在接收到文件存储指令时,确定待存储的文件对应的文件名;
    对确定的文件名进行特征计算,以得到特征值;
    采用文件目录的总数对所述特征值取模,以得到模值,其中,取模的方式为:采用文件目录的总数除以所述特征值;
    基于所述模值确定所述文件名对应的序号;
    基于预设序号与目录的映射关系,确定所述序号对应的目录,并将所述文件存储到确定的目录中。
  2. 如权利要求1所述的文件存储方法,其特征在于,所述对确定的文件名进行特征计算,以得到特征值的步骤包括:
    基于预存的二进制对照表,查询文件名对应的二进制值;
    通过预设的哈希函数将所述二进制值映射成固定长度的二进制值,将所述固定长度的二进制值作为特征值。
  3. 如权利要求1所述的文件存储方法,其特征在于,所述对确定的文件名进行特征计算,以得到特征值的步骤还包括:
    获取预存编码表;
    基于预存编码表中文件名与编码值的对应关系,获取所述文件名对应的编码值,将获取的所述编码值作为特征值。
  4. 如权利要求1所述的文件存储方法,其特征在于,所述基于预设序号与目录的映射关系,确定所述序号对应的目录,并将所述文件存储到确定的目录中的步骤之后,所述方法还包括:
    在接收到文件读取指令时,基于所述文件读取指令中携带的文件名确定待读取文件所在的目录;
    在确定的目录中读取文件。
  5. 如权利要求4所述的文件存储方法,其特征在于,所述在接收到文件读取指令时,基于所述文件读取指令中携带的文件名确定待读取文件所在的目录的步骤包括:
    确定所述文件读取指令中携带的文件名;
    对文件名进行特征计算,以得到特征值;
    根据文件目录的总数对所述文件名对应的特征值取模,以确定待读取文件所在的目录。
  6. 如权利要求4所述的文件存储方法,其特征在于,所述在接收到文件读取指令时,基于所述文件读取指令中携带的文件名确定待读取文件所在的目录的步骤之后,所述方法还包括:
    在确定的目录中读取不到文件时,查询变更前的目录总数;
    根据变更前的目录总数对待读取文件的文件名对应的特征值取模,以得到文件目录;
    在所述文件目录中读取文件。
  7. 如权利要求1所述的文件存储方法,其特征在于,所述方法还包括:
    在检测到目录的存储容量达到预设容量值时,若接收到目录的扩充指令,确定待扩充目录的个数;
    在系统中新增确定个数的目录。
  8. 如权利要求2所述的文件存储方法,其特征在于,所述方法还包括:
    在检测到目录的存储容量达到预设容量值时,若接收到目录的扩充指令,确定待扩充目录的个数;
    在系统中新增确定个数的目录。
  9. 如权利要求3所述的文件存储方法,其特征在于,所述方法还包括:
    在检测到目录的存储容量达到预设容量值时,若接收到目录的扩充指令,确定待扩充目录的个数;
    在系统中新增确定个数的目录。
  10. 如权利要求4所述的文件存储方法,其特征在于,所述方法还包括:
    在检测到目录的存储容量达到预设容量值时,若接收到目录的扩充指令,确定待扩充目录的个数;
    在系统中新增确定个数的目录。
  11. 如权利要求5所述的文件存储方法,其特征在于,所述方法还包括:
    在检测到目录的存储容量达到预设容量值时,若接收到目录的扩充指令,确定待扩充目录的个数;
    在系统中新增确定个数的目录。
  12. 如权利要求6所述的文件存储方法,其特征在于,所述方法还包括:
    在检测到目录的存储容量达到预设容量值时,若接收到目录的扩充指令,确定待扩充目录的个数;
    在系统中新增确定个数的目录。
  13. 如权利要求1所述的文件存储方法,其特征在于,所述方法还包括:
    在检测到目录的存储容量达到预设容量值时,若接收到目录的清空指令,将目录的文件备份至预设存储区中;
    在文件备份完成后,清空所述目录。
  14. 如权利要求2所述的文件存储方法,其特征在于,所述方法还包括:
    在检测到目录的存储容量达到预设容量值时,若接收到目录的清空指令,将目录的文件备份至预设存储区中;
    在文件备份完成后,清空所述目录。
  15. 如权利要求3所述的文件存储方法,其特征在于,所述方法还包括:
    在检测到目录的存储容量达到预设容量值时,若接收到目录的清空指令,将目录的文件备份至预设存储区中;
    在文件备份完成后,清空所述目录。
  16. 如权利要求4所述的文件存储方法,其特征在于,所述方法还包括:
    在检测到目录的存储容量达到预设容量值时,若接收到目录的清空指令,将目录的文件备份至预设存储区中;
    在文件备份完成后,清空所述目录。
  17. 如权利要求5所述的文件存储方法,其特征在于,所述方法还包括:
    在检测到目录的存储容量达到预设容量值时,若接收到目录的清空指令,将目录的文件备份至预设存储区中;
    在文件备份完成后,清空所述目录。
  18. 如权利要求6所述的文件存储方法,其特征在于,所述方法还包括:
    在检测到目录的存储容量达到预设容量值时,若接收到目录的清空指令,将目录的文件备份至预设存储区中;
    在文件备份完成后,清空所述目录。
  19. 一种终端,其特征在于,所述终端包括存储器、处理器及存储在所述存储器上并可在所述处理器上运行的文件存储程序,所述文件存储程序被所述处理器执行时实现如权利要求1所述的文件存储方法的步骤。
  20. 一种计算机可读存储介质,其特征在于,所述计算机可读存储介质上存储有文件存储程序,所述文件存储程序被处理器执行时实现如权利要求1所述的文件存储方法的步骤。
PCT/CN2017/103545 2017-07-27 2017-09-26 文件存储方法、终端和计算机可读存储介质 WO2019019341A1 (zh)

Priority Applications (2)

Application Number Priority Date Filing Date Title
US16/318,696 US20200293490A1 (en) 2017-07-27 2017-09-26 File storing method, terminal, and computer-readable storage medium
SG11201902727TA SG11201902727TA (en) 2017-07-27 2017-09-26 File storing method, terminal, and computer-readable storage medium

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201710622747.4A CN107562786A (zh) 2017-07-27 2017-07-27 文件存储方法、终端和计算机可读存储介质
CN201710622747.4 2017-07-27

Publications (1)

Publication Number Publication Date
WO2019019341A1 true WO2019019341A1 (zh) 2019-01-31

Family

ID=60974998

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2017/103545 WO2019019341A1 (zh) 2017-07-27 2017-09-26 文件存储方法、终端和计算机可读存储介质

Country Status (4)

Country Link
US (1) US20200293490A1 (zh)
CN (1) CN107562786A (zh)
SG (1) SG11201902727TA (zh)
WO (1) WO2019019341A1 (zh)

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109189728B (zh) * 2018-07-18 2022-08-12 深圳市网心科技有限公司 智能硬件设备、磁盘数据处理方法和存储介质
CN111611208A (zh) * 2020-05-27 2020-09-01 北京太极华保科技股份有限公司 文件存储与查询的方法及装置、存储介质
CN114442937B (zh) * 2021-12-31 2023-03-28 北京云宽志业网络技术有限公司 文件缓存方法、装置、计算机设备及存储介质

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101772207A (zh) * 2008-12-29 2010-07-07 上海闻泰电子科技有限公司 一种移动终端设备标识文件的方法
JP2012119905A (ja) * 2010-11-30 2012-06-21 Canon Inc 記録再生装置、その記録再生方法およびプログラム
CN103384256A (zh) * 2012-05-02 2013-11-06 天津书生投资有限公司 一种云存储方法及装置
CN106446001A (zh) * 2016-07-29 2017-02-22 北京北信源软件股份有限公司 一种在计算机存储介质上存储文件的方法及系统

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101404029B (zh) * 2008-11-04 2011-06-22 深圳市蓝韵实业有限公司 一种dicom图像文件存储方法
CN101719141B (zh) * 2009-12-24 2011-09-07 成都市华为赛门铁克科技有限公司 基于目录对象的文件处理方法和系统
CN102904931A (zh) * 2012-09-19 2013-01-30 河南锐之旗信息技术有限公司 一种图片存储与读取方法
CN106776891A (zh) * 2016-11-30 2017-05-31 山东浪潮商用系统有限公司 一种文件存储的方法和装置

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101772207A (zh) * 2008-12-29 2010-07-07 上海闻泰电子科技有限公司 一种移动终端设备标识文件的方法
JP2012119905A (ja) * 2010-11-30 2012-06-21 Canon Inc 記録再生装置、その記録再生方法およびプログラム
CN103384256A (zh) * 2012-05-02 2013-11-06 天津书生投资有限公司 一种云存储方法及装置
CN106446001A (zh) * 2016-07-29 2017-02-22 北京北信源软件股份有限公司 一种在计算机存储介质上存储文件的方法及系统

Also Published As

Publication number Publication date
SG11201902727TA (en) 2019-05-30
CN107562786A (zh) 2018-01-09
US20200293490A1 (en) 2020-09-17

Similar Documents

Publication Publication Date Title
WO2018076841A1 (zh) 数据分享方法、装置、存储介质及服务器
WO2017069595A1 (en) Electronic device and method for executing function using speech recognition thereof
WO2018076865A1 (zh) 数据分享方法、装置、存储介质及电子设备
WO2018076889A1 (zh) 数据备份的方法、装置、系统、存储介质及服务器
WO2018076867A1 (zh) 数据备份的删除方法、装置、系统、存储介质和服务器
WO2018076818A1 (zh) 数据的备份方法、装置、电子设备、存储介质及系统
WO2018233352A1 (zh) 数据传输方法、装置、终端以及计算机可读存储介质
WO2018201774A1 (zh) 数据审批方法、装置、设备和计算机可读存储介质
WO2019019341A1 (zh) 文件存储方法、终端和计算机可读存储介质
WO2017092498A1 (zh) 一种信息管理方法及用户终端
WO2018076844A1 (zh) 数据备份的方法、装置、存储介质及电子设备
WO2018076829A1 (zh) 终端数据的处理方法、装置、系统、存储介质及服务器
WO2016101441A1 (zh) 一种进行文件同步的方法及系统
WO2016183721A1 (zh) 一种终端设备刷机方法、装置和设备
WO2018026164A1 (en) Method of processing touch events and electronic device adapted thereto
WO2018076881A1 (zh) 数据同步方法、装置、存储介质及服务器
WO2021012481A1 (zh) 系统性能监控方法、装置、设备及存储介质
WO2017148142A1 (zh) 桌面图标文件夹的名称切换方法、装置及电子设备
WO2018076863A1 (zh) 数据存储的方法、装置、存储介质、服务器及系统
WO2017185647A1 (zh) 基于SoftSIM的IMSI号码管理及呼叫方法、服务器及网络侧设备
WO2018076869A1 (zh) 一种数据备份方法、装置、存储介质和电子设备
WO2020062615A1 (zh) 显示面板的伽马值调节方法、装置及显示设备
WO2018076890A1 (zh) 数据备份的方法、装置、存储介质、服务器及系统
WO2018076873A1 (zh) 数据分享方法、装置、介质、电子设备及系统
WO2020177376A1 (zh) 数据的提取方法、装置、终端及计算机可读存储介质

Legal Events

Date Code Title Description
NENP Non-entry into the national phase

Ref country code: DE

32PN Ep: public notification in the ep bulletin as address of the adressee cannot be established

Free format text: NOTING OF LOSS OF RIGHTS PURSUANT TO RULE 112(1) EPC (EPO FORM 1205A DATED 06/08/2020)

122 Ep: pct application non-entry in european phase

Ref document number: 17919605

Country of ref document: EP

Kind code of ref document: A1