| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | dos2unix |
Sat 2003-06-21 12:08, Roy J. Tellason (1:270/615) wrote to andrew clarke:
RJT> There are a couple of bits of that program you posted that I'm not
RJT> sure of. For example, this stuff:
RJT> #ifdef __GNUC__
RJT> #include
RJT> #include
RJT> #else
RJT> #include
RJT> #include
RJT> #endif
If compiling under GNU C, include unistd.h & utime.h, otherwise include
io.h and sys/utime.h. Different brands of compilers can be inconsistent as
to where certain prototypes and other things (that are not in the ISO C
standard) are located.
RJT> static struct stat s_buf;
Declare a variable of type struct stat and call it s_buf. Make it static,
ie. local to this .c file only, which has the side effect of setting all
its values to zero during program startup.
RJT> and these bits here:
RJT> ut_buf.actime = s_buf.st_atime;
RJT> ut_buf.modtime = s_buf.st_mtime;
RJT> What are those for?
s_buf is obtained from the file system by using stat(). Among other things
struct stat contains the file's "last access" time and "last
modified" time. struct utimbuf is used for writing this information
back to the file system by way of the utime() function. So we're setting
the timestamp of the newly create file to the timestamp of the original
file. Then we delete the old file and rename the new file to the old
file's name.
-- mail{at}ozzmosis.com
--- timEd/FreeBSD 1.11.b1
* Origin: Blizzard of Ozz, Mt Eliza, Melbourne, Australia (3:633/267)SEEN-BY: 633/267 270 @PATH: 633/267 |
|
| SOURCE: echomail via fidonet.ozzmosis.com | |
Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.