The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Programming Languages
> C Programming
|
FileTime???
Discuss FileTime??? in the C Programming forum on Dev Shed. FileTime??? C programming forum discussing all C derivatives, including C#, C++, Object-C, and even plain old vanilla C. These languages are low level languages, and used on projects such as device drivers, compilers, and even whole computer operating systems.
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

October 24th, 2002, 07:28 AM
|
 |
Some day I will be a Lambda!
|
|
Join Date: Jun 2002
Location: NJ
Posts: 18
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
FileTime???
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
|

October 24th, 2002, 12:31 PM
|
 |
Banned ;)
|
|
Join Date: Nov 2001
Location: Woodland Hills, Los Angeles County, California, USA
|
|
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!
|

October 24th, 2002, 05:03 PM
|
 |
Some day I will be a Lambda!
|
|
Join Date: Jun 2002
Location: NJ
Posts: 18
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
As always - You are the Man
I'll post back and let you know if this helps.
Thanks
Eric
|

October 24th, 2002, 05:18 PM
|
 |
Some day I will be a Lambda!
|
|
Join Date: Jun 2002
Location: NJ
Posts: 18
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
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.
|

November 7th, 2002, 06:37 PM
|
 |
Some day I will be a Lambda!
|
|
Join Date: Jun 2002
Location: NJ
Posts: 18
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
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
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|