|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now! |
|
#1
|
||||
|
||||
|
Question:
I have a program that parses through a directory and gathers information. I'm now trying to trim the parse time down, it takes about 130 seconds to parse 10 gigs on a PIII 600 with 256 RAM. I can cut the time in almost half if I remove the file time functionality. I'm getting the Create, Last Viewed, and Last Modified times of each and every file on the system. Below I have included some code that I just ripped out of my program. I modified it a little just to make it look right. I have enclosed it so that I can show the logic that I'm using. If anyone has any idea of how I can accomplish this task a little more efficient I would be very grateful. Code:
TCHAR *szPath; // The path of the folder / directory
TCHAR szCurDirPath[400];
TCHAR szTemp[5];
TCHAR szDate[10];
sprintf(szCurDirPath, "%s*.*", szPath);
hFind = FindFirstFile(szCurDirPath, &data);
data.ftCreationTime
if ( FileTimeToSystemTime(&data.ftCreationTime, &stCreate) != 0 )
ConvertFileTime(sCreateDate, stCreate);
_itoa(stCreate.wMonth, szTemp, 10);
sprintf(szDate, "%s-", szTemp);
_itoa(stCreate.wDay, szTemp, 10);
sprintf(szDate, "%s-", szTemp);
_itoa(stCreate.wYear, szTemp, 10);
sprintf(szDate, szTemp);
printf("%s\n", szDate);
Thank you Eric |
|
#2
|
||||
|
||||
|
Why not just use sprintf() once and avoid using all the _itoa calls.
As a bonus, you can also get rid of szTemp, if you write your code something like this: Code:
if ( FileTimeToSystemTime(&data.ftCreationTime, &stCreate) != 0 )
sprintf(szDate, "%d-%d-%d", stCreate.wMonth, stCreate.wDay, stCreate.wYear);
printf("%s\n", szDate);
Hope this helps! |
|
#3
|
||||
|
||||
|
As always - You are the Man
I'll post back and let you know if this helps. Thanks Eric |
|
#4
|
||||
|
||||
|
Scorpions4ever
That modification added 10 seconds on the scan time. I'll reboot and see if it's becouse of other software running. Eric - - After the reboot the run time was almost the same as before the modification. Last edited by Beans4You : October 24th, 2002 at 07:13 PM. |
|
#5
|
||||
|
||||
|
Still doing research trying to figure this one out...
Now I have not used any real MFC programming and I'm a little scarred of it, but I found this function CTimeSpan which looks like it might be able to help me. This function can return the total number of days and hopefully remove allot of unnecessary conversions that I'm doing. I'm thinking something like: (FileTime_TotalDays - SystemTime_TotalDays) = number of days since {last view, modified, accessed}. Can this be done? And if it can, does anyone know how to change filetime to CTimeSpan? Also, this program is just a normal C++ command line program, what changes will I need to implement to use an MFC function? Eric |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > C Programming > FileTime??? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|