|
Register or have you forgotten your password?
|
|
|
| Amiga OS -- Development This particular forum deals with issues regarding development for all versions of AmigaOS. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 | ||||||||
|
Premium Member
Join Date: Nov 2003
Location: Houston, Texas
Posts: 2,257
|
How do I check size and date of a file in ANSI C?
__________________
Wanna try a wonderfull strategy game with lots of handdrawn anims, Magic Spells and Monsters, Incredible playability and lastability, English speech, etc. Total Chaos AGA |
||||||||
|
|
|
|
|
#2 | ||||||||
|
Cult Member
![]()
Join Date: Feb 2002
Location: Antarctica
Posts: 936
|
I usually use stat() or lstat() though these might be more Unix specific???
More details in this thread. |
||||||||
|
|
|
|
|
#3 | ||||||||
|
Desperately needs a life
![]()
Join Date: Sep 2003
Posts: 3,056
|
There's no function to get file date in pure ANSI C. But, look for stat() like Castellen mentioned.
__________________
Time to move on. Bye Amiga.org.
|
||||||||
|
|
|
|
|
#4 | ||||||||
|
Premium Member
Join Date: Nov 2003
Location: Houston, Texas
Posts: 2,257
|
I am already using stat() but the problem is that stat() in SASC triggers a read of a nonexistent environment variable TZ which is lame and slow. I am doing thousands of stat() in a loop.
Accessing an environment variable for no reason every time you check the existence of a file sounds like something linux would do. So that is why I was searching for a cleaner way that is also multiplatform.Does stat() in all compilers trigger this lame environment variable access? Or is it just some stupid thing in SASC? Its easy to run SnoopDos to check. How can I do surgery on my SASC to amputate the offending code? ![]() p.s. what the heck is the difference between stat() and lstat() ? ![]() |
||||||||
|
|
|
|
|
#5 | ||||||||
|
Cult Member
![]()
|
Why not #ifndef around the block and add AmigaOS-specific replacement code?
You can use Lock() and Examine() or Open() and ExamineFH() to get a FileInfoBlock, which will tell you the date and size. Chris
__________________
"Miracles we do at once, the impossible takes a little longer" - AJS on Hyperion Avatar picture is Tabitha by Eric W Schwartz |
||||||||
|
|
|
|
|
#6 | ||||||||
|
Premium Member
Join Date: Nov 2003
Location: Houston, Texas
Posts: 2,257
|
@chris
The deal is that I could do your idea but I would have to do it in many different places and the code is already around 200,000 lines and adding a bunch of giant blocks of #ifdef AMIGA code would really messify things... Do you know any secret trick to do it super elegantly and simply? :-) |
||||||||
|
|
|
|
|
#7 | ||||||||
|
Sockologist
![]()
|
Why not simply write a wrapper function that does the job you need and simply have the implementation of that function #ifdef AMIGA ?
__________________
OCA This isn't SCSI... This is SATA!!! I have CDO. It's like OCD except all the letters are in ascending order. The way they should be. Core2 Quad Q9450 2.66GHz / X48T / 4GB DDR3 / nVidia GTX275 / Linux x64, AROS, Win64 A1XE 800MHz / 512MB / Radeon 9200 / OS4.1 A1200T BPPC 240MHz / 256MB / Permedia 2 / OS 3.1 - OS3.9, OS4 A1200T Apollo 1240 28MHz / 32MB / Mediator1200 / Voodoo 3000 / OS3.9 A1200D Apollo 1240 25MHz (ejector seat ROM edition) / 32MB |
||||||||
|
|
|
|
|
#8 | |||||||||||
|
Defender of the Faith
![]()
Join Date: Nov 2002
Posts: 1,031
|
Quote:
Quote:
Quote:
__________________
Some people say that cats are sneaky, evil and cruel. True, and they have many other fine qualities as well. |
|||||||||||
|
|
|
|
|
#9 | ||||||||||||
|
Premium Member
Join Date: Nov 2003
Location: Houston, Texas
Posts: 2,257
|
Quote:
that uses AmigaOS way of doing things that will fill in a unix struct stat so all the time compare code will work without change. BUT... how do I convert from AmigaDOS time format to Unix time_t format? Quote:
time that some file was created many years ago on someone elses computer... Does it? I guess you are saying that linux constantly converts all filedates to/from GMT? So all filedates in linux are stored on the HD in GMT? And since AmigaOS does not store filedates in GMT but instead stores the actual date where it was created, the stat() function in SASC should be rewritten to NOT check TZ since adding in the user's TimeZone under AmigaOS would then give the wrong date. Correct? |
||||||||||||
|
|
|
|
|
#10 | |||||||||
|
Premium Member
Join Date: Nov 2003
Location: Houston, Texas
Posts: 2,257
|
Quote:
But I donno how to convert from Amiga time to Unix time_t time. :-? |
|||||||||
|
|
|
|
|
#11 | ||||||||
|
Sockologist
![]()
|
Don't both systems measure time (32-bit integer) as the number of seconds since a particular epoch date?
If so, provided you know the difference between them. If memory serves, the Unix epoch is 00:00:00 Jan 01 1970 and the Amiga epoch is 00:00:00 Jan 01 1978 I would assume, if you evaluate the amiga epoch date as a unix datestamp you have a displacement you can use to convert an amiga 32-bit datestamp to a unix one and vice versa.
__________________
OCA This isn't SCSI... This is SATA!!! I have CDO. It's like OCD except all the letters are in ascending order. The way they should be. Core2 Quad Q9450 2.66GHz / X48T / 4GB DDR3 / nVidia GTX275 / Linux x64, AROS, Win64 A1XE 800MHz / 512MB / Radeon 9200 / OS4.1 A1200T BPPC 240MHz / 256MB / Permedia 2 / OS 3.1 - OS3.9, OS4 A1200T Apollo 1240 28MHz / 32MB / Mediator1200 / Voodoo 3000 / OS3.9 A1200D Apollo 1240 25MHz (ejector seat ROM edition) / 32MB |
||||||||
|
|
|
![]() |
| Bookmarks |
| Tags |
| size or date , ansi , file , check |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| ansi capable telnet application for OS3.x? | AmiKit | Amiga Software Issues and Discussion | 5 | 04-09-2009 12:37 PM |
| Octamed tutorials biggest file size >720kb | ElZorro | Amiga Software Issues and Discussion | 10 | 12-26-2006 03:11 AM |
| OS call to get file size | gazsp | Amiga OS -- Development | 7 | 01-28-2006 03:20 PM |
| The size of a file | srg86 | Amiga OS -- Development | 6 | 05-04-2005 07:08 AM |
| More GNU C++ (ANSI C++ mode) oddness | Karlos | Amiga OS -- Development | 14 | 03-26-2004 11:02 AM |