A folder capacity statistics method and system

By monitoring folder change events through the MFT master file table and Windows API, combined with caching and real-time calculation, the problem of Windows Explorer taking a long time to calculate folder size is solved, and folder capacity can be quickly displayed.

CN117149712BActive Publication Date: 2025-10-21FUJIAN TQ ONLINE INTERACTIVE INC
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202311040811.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-08-18
Publication Date
2025-10-21
Estimated Expiration
2043-08-18

AI Technical Summary

Technical Problem

In the prior art, Windows Explorer needs to restart the calculation when counting the size of a folder, which results in a time-consuming problem.

Method used

The system quickly counts folder sizes through the MFT master file table and saves them in the memory cache. It monitors folder change events and uses real-time calculation or cache acquisition to select the calculation method based on the folder change frequency.

Benefits of technology

When there are a large number of files, the folder size is quickly displayed, which improves statistical efficiency and display speed.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117149712B_ABST
    Figure CN117149712B_ABST
Patent Text Reader

Abstract

The present application relates to a kind of folder capacity statistical methods, the method steps are as follows: step 1: the size of existing folder is quickly counted by MFT main file table, save in memory cache;Step 2: the change event of folder is monitored;Step 3: if folder event changes, then the relevant folder is counted, and counting is carried out under the corresponding time node, and change information is added;Step 4: if file folder changes frequently, then the folder capacity is recursively calculated using real-time calculation method, otherwise, the size of folder is directly obtained by reading cache, a kind of folder capacity statistical method and system provided by the present application can show folder size faster in the case where there are many files.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of folder capacity statistics, and in particular to a folder capacity statistics method and system. Background Art

[0002] In computer-related technologies, in order to determine the storage space occupied by an application, the electronic device needs to scan the size of the storage space occupied by all subfolders under the root directory of the application one by one (in this disclosure, the size of the storage space occupied by a folder is also referred to as the size (capacity) of the folder), and accumulate the sizes of these subfolders to determine the size of the storage space occupied by the application.

[0003] Currently, Windows Explorer only counts file sizes. For folder size statistics, it needs to restart the calculation each time. When the folder content becomes larger and larger, the statistics time will also become longer and time-consuming. Summary of the Invention

[0004] To overcome the problem that Windows Explorer only counts file sizes, folder size statistics need to be recalculated, which is time-consuming.

[0005] The present invention is implemented by the following scheme:

[0006] A method for counting folder capacity, the method steps are as follows:

[0007] Step 1: Quickly count the size of existing folders through the MFT master file table and save it in the memory cache;

[0008] Step 2: Listen for folder change events;

[0009] Step 3: If the folder event changes, count the relevant folders and count them at the corresponding time node, and add change information;

[0010] Step 4: If the frequency of file folder changes is high, the folder capacity is recursively calculated using real-time calculation. Otherwise, the folder size is obtained directly by reading the cache.

[0011] Furthermore, step 1 is further specified as follows: by parsing the MFT master file table, traversing the files in the folder, and reading the file sizes from the attributes of the MFT table for accumulation.

[0012] Furthermore, step 2 is further specified as follows: reading disk change information and monitoring folder change events by setting the ReadDirectoryChangesW function in the Windows API.

[0013] Furthermore, step 3 is further specified as follows: if the folder event changes, the size of the changed folder and all its parent folders will be updated, and the count will be increased and the change information will be added in the daily count data, weekly count data, monthly count data, and yearly count data, and the change information includes the file path and file size.

[0014] Furthermore, step 4 is further specified as follows: determine whether the folder size changes more than once per hour. If so, the frequency is high, and the folder capacity is recursively calculated using real-time calculation. Otherwise, directly read the cache, obtain the resource manager folder display position, and render the folder size at the top level of the resource manager folder, overwriting the original folder position to check the folder size.

[0015] A folder capacity statistics system, comprising: a fast statistics module, a monitoring module, a counting module, and a folder size acquisition module;

[0016] The fast statistics module is used to quickly count the size of existing folders through the MFT master file table and save it in the memory cache;

[0017] The monitoring module is used to monitor the change events of the folder;

[0018] The counting module is used to count the relevant folders if the folder event changes, and count at the corresponding time node and add change information;

[0019] The folder size acquisition module is used to recursively calculate the folder capacity in real time if the frequency of file folder changes is high; otherwise, the folder size is directly obtained by reading the cache.

[0020] Furthermore, the fast statistics module is further specifically as follows: by parsing the MFT master file table, traversing the files in the folder, reading the file sizes from the attributes of the MFT table and accumulating them.

[0021] Furthermore, the monitoring module is further specifically configured to monitor folder change events by reading disk change information through setting the ReadDirectoryChangesW function in the Windows API.

[0022] Furthermore, the counting module is further specified as follows: if a folder event changes, the size of the changed folder and all its parent folders will be updated, and the count amount will be increased and the change information will be added in the daily counting data, weekly counting data, monthly counting data and annual counting data, and the change information includes the file path and file size.

[0023] Furthermore, the folder size acquisition module is further specified as follows: determine whether the folder size changes more than once per hour. If so, the frequency is high, and the folder capacity is recursively calculated using real-time calculation. Otherwise, obtain the resource manager folder display position, and render the folder size at the top level of the resource manager folder, overwriting the original folder position, and read the cache to view the folder size.

[0024] The beneficial effect of the present invention is that the folder capacity statistics method and system provided by the present invention can display the folder size more quickly when there are a large number of files. BRIEF DESCRIPTION OF THE DRAWINGS

[0025] Figure 1 Schematic diagram of the process of the present invention;

[0026] Figure 2 It is a structural block diagram of the system of the present invention. DETAILED DESCRIPTION

[0027] The present invention will be further described below with reference to the accompanying drawings.

[0028] See Figure 1 A method for counting folder capacity is provided, wherein the steps are as follows:

[0029] Step 1: Quickly count the size of existing folders through the MFT master file table and save it in the memory cache;

[0030] Step 2: Listen for folder change events;

[0031] Step 3: If the folder event changes, count the relevant folders and count them at the corresponding time node, and add change information;

[0032] Step 4: If the frequency of file folder changes is high, the folder capacity is recursively calculated using real-time calculation. Otherwise, the folder size is obtained directly by reading the cache.

[0033] The present invention will be further described below with reference to a specific embodiment:

[0034] A method for counting folder capacity, comprising:

[0035] By parsing the MFT master file table, traversing the files in the folder, and reading the file sizes from the MFT table attributes for accumulation;

[0036] The size of folder D:\Folder 1 calculated from MFT is 100M;

[0037] Set the ReadDirectoryChangesW function in Windows API to read disk change information and monitor folder change events;

[0038] Set ReadDirectoryChangesW to listen for events on D:\folder 1.

[0039] If a folder event changes, the size of the changed folder and all its parent folders is updated, and the count and change information are increased in the daily count data, the weekly count data, the monthly count data, and the yearly count data. The change information includes the file path and file size.

[0040] If D:\Folder1\File1.txt under D:\Folder1 is changed, the original D:\Folder1 daily change count is 0, weekly change count is 1, monthly change count is 10, and annual change count is 20. After cumulative count, the daily change count is 1, weekly change count is 2, monthly change count is 11, and annual change count is 21.

[0041] Determine whether the folder size changes more than once per hour. If so, the frequency is high, and the folder capacity is recursively calculated using real-time calculation. Otherwise, directly read the cache, obtain the Explorer folder display position, and render the folder size at the top level of the Explorer folder, overwriting the original folder position to check the folder size.

[0042] During recursive calculation, if a subdirectory has a low frequency of changes, the capacity of the subdirectory in the cache can be directly obtained, without recursively calculating all folders, which can also improve the statistical speed.

[0043] If the size of D:\Folder 1 does not change more than once per hour, the previous size of D:\Folder 1 is read directly from the cache and displayed directly.

[0044] See Figure 2 , a folder capacity statistics system, the system includes: a fast statistics module, a monitoring module, a counting module, and a folder size acquisition module;

[0045] The fast statistics module is used to quickly count the size of existing folders through the MFT master file table and save it in the memory cache;

[0046] The monitoring module is used to monitor the change events of the folder;

[0047] The counting module is used to count the relevant folders if the folder event changes, and count at the corresponding time node and add change information;

[0048] The folder size acquisition module is used to recursively calculate the folder capacity in real time if the frequency of file folder changes is high; otherwise, the folder size is directly obtained by reading the cache.

[0049] The quick statistics module is further specifically as follows: by parsing the MFT master file table, traversing the files in the folder, reading the file sizes from the attributes of the MFT table and accumulating them.

[0050] The monitoring module is further specified as follows: reading disk change information and monitoring folder change events by setting the ReadDirectoryChangesW function in the Windows API.

[0051] The counting module is further specified as follows: if a folder event changes, the size of the changed folder and all its parent folders will be updated, and the count amount will be increased and the change information will be added in the daily counting data, weekly counting data, monthly counting data and annual counting data, and the change information includes the file path and file size.

[0052] The folder size acquisition module is further specified as follows: determine whether the folder size changes more than once per hour. If so, the frequency is high, and the folder capacity is recursively calculated using real-time calculation. Otherwise, obtain the resource manager folder display position and render the folder size at the top level of the resource manager folder, overwriting the original folder position, and read the cache to view the folder size.

[0053] In summary, the folder capacity statistics method and system provided by the present invention can display the folder size more quickly when there are a large number of files.

[0054] The above description is only a preferred embodiment of the present invention. All equivalent changes and modifications made according to the scope of the patent application of the present invention should fall within the scope of the present invention.

Claims

1. A folder capacity statistics method, characterized in that: The method steps are as follows: Step 1: Quickly count the size of existing folders through the MFT master file table and save it in the memory cache; Step 2: Listen for folder change events; Step 3: If the folder event changes, count the relevant folders and count them at the corresponding time node, and add change information; Step 4: If the folder changes frequently, recursively calculate the folder capacity using real-time calculation. Otherwise, directly read the cache to obtain the folder size. Step 3 is further specifically as follows: if a folder event is changed, the size of the changed folder and all its parent folders is updated, and the count amount and change information are increased in the daily count data, the weekly count data, the monthly count data, and the yearly count data, wherein the change information includes the file path and the file size; Step 4 is further specified as follows: determine whether the folder size changes more than once per hour. If so, the frequency is high, and the folder capacity is recursively calculated using real-time calculation. Otherwise, directly read the cache, obtain the resource manager folder display position, and render the folder size at the top level of the resource manager folder, overwriting the original folder position to check the folder size.

2. A folder capacity statistics method according to claim 1, characterized in that: Step 1 is further specifically as follows: by parsing the MFT master file table, traversing the files in the folder, and reading the file sizes from the attributes of the MFT table for accumulation.

3. A folder capacity statistics method according to claim 1, characterized in that: Step 2 is further specified as follows: reading disk change information and monitoring folder change events by setting the ReadDirectoryChangesW function in WindowsApi.

4. A folder capacity statistics system, characterized in that: The system includes: a fast statistics module, a monitoring module, a counting module, and a folder size acquisition module; The fast statistics module is used to quickly count the size of existing folders through the MFT master file table and save it in the memory cache; The monitoring module is used to monitor the change events of the folder; The counting module is used to count the relevant folders if the folder event changes, and count at the corresponding time node and add change information; The folder size acquisition module is used to recursively calculate the folder capacity in real time if the folder changes frequently, otherwise, directly obtain the folder size by reading the cache; The counting module is further specifically configured to: if a folder event changes, update the size of the changed folder and all its parent folders, and increase the count and change information in the daily counting data, the weekly counting data, the monthly counting data, and the annual counting data, wherein the change information includes the file path and the file size; The folder size acquisition module is further specified as follows: determine whether the folder size changes more than once per hour. If so, the frequency is high, and the folder capacity is recursively calculated using real-time calculation. Otherwise, obtain the resource manager folder display position and render the folder size at the top level of the resource manager folder, overwriting the original folder position, and read the cache to view the folder size.

5. A folder capacity statistics system according to claim 4, characterized in that: The quick statistics module is further specifically as follows: by parsing the MFT master file table, traversing the files in the folder, reading the file sizes from the attributes of the MFT table and accumulating them.

6. A folder capacity statistics system according to claim 4, characterized in that: The monitoring module is further specified as follows: reading disk change information by setting the ReadDirectoryChangesW function in WindowsApi to monitor folder change events.

Citation Information

Patent Citations

  • Method and system for displaying size of folder of mobile terminal, and mobile terminal

    CN106021473A

  • File information statistics method and device and electronic equipment

    CN114996224A