| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | dos2unix |
andrew clarke wrote in a message to Roy J. Tellason: ac> Sat 2003-06-21 12:08, Roy J. Tellason (1:270/615) wrote to andrew ac> 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 ac> If compiling under GNU C, include unistd.h & utime.h, otherwise ac> include io.h and sys/utime.h. Different brands of compilers can be ac> inconsistent as to where certain prototypes and other things (that ac> are not in the ISO C standard) are located. I got the conditional, I just don't know what those headers are for. I suppose I could find them and have a look? :-) RJT> static struct stat s_buf; ac> Declare a variable of type struct stat and call it s_buf. Make it ac> static, ie. local to this .c file only, which has the side effect ac> of setting all its values to zero during program startup. That side effect is an interesting tidbit, I hadn't remembered that. But then I wouldn't have expected any initialization to take place unless I put some in there, so not remembering that wouldn't have been a problem. 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? ac> s_buf is obtained from the file system by using stat(). Among ac> other things struct stat contains the file's "last access" time and ac> "last modified" time. struct utimbuf is used for writing this ac> information back to the file system by way of the utime() function. Ok, there are a couple of things I wasn't familiar with... ac> So we're setting the timestamp of the newly create file to the ac> timestamp of the original file. I like it! ac> Then we delete the old file and rename the new file to the old ac> file's name. Yep. The thing as a whole works well, and I can see where the basic framework might be useful for some other things as well. ---* Origin: TANSTAAFL BBS 717-838-8539 (1:270/615) SEEN-BY: 633/267 270 @PATH: 270/615 150/220 379/1 106/1 2000 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™.