Mail Archives: cygwin/1997/06/13/20:54:51
Keet wrote:
>
> The following C code example, is proof that RENAME() or UNLINK() does not
> work reliably. After being told so many times it's the source's fault, I'm
> relieved to have found someone who knows what they're talking about and who
> could help me with this. What's happening is that when a file is unlinked,
> it isn't really unlinked. From what I'm told, there is no way to UNLINK an
> open file under a FAT based system. This is because in a FAT based system,
> the filename IS the file.. under UNIX, this is not the case. How you got
> around that, is beyond me. From what I can tell, the file is NOT unlinked,
> because when the following test program ends, test1 still exists. If this is
> not the case, then it's still failing to rename, because I get an error, and
> both test1 and test2 still exist. This isn't normal operation. Under 17.1
> this worked lovely, no problem at all. It even worked in Linux.. but under
> 18.. it messes up completely. If anyone can offer any help to me.. please
> reply ASAP.
>
> ==============================START TEST.C====================================
>
> /* rename() and unlink() failure */
> #include <stdio.h>
>
> main()
> {
> FILE *test1,*test2;
>
> if( (test1=fopen("test1","w")) == NULL) {
> printf("Unable to fopen() test1!\n");
> exit(1);
> }
>
> if( (test2=fopen("test2","w")) == NULL) {
> printf("Unable to fopen() test2!\n");
> exit(1);
> }
>
> if( fputs("This is test 1...\n",test1) < 0) {
> printf("Unable to write to test1!\n");
> exit(1);
> }
>
> if( fputs("This is test 2...\n",test2) < 0) {
> printf("Unable to write to test2!\n");
> exit(1);
> }
Try moving these to here:
fclose(test1);
fclose(test2);
> if( unlink("test1") < 0) {
> printf("Unable to unlink test1!\n");
> exit(1);
> }
>
> if( rename("test2","test1") < 0 ) {
> printf("Unable to rename test2 to test1!\n");
> exit(1);
> }
>
> fclose(test1);
> fclose(test2);
And delete from here.
> }
>
> ==================================END TEST.C=================================
--
,-/- __ _ _ $Bill Luebkert
(_/ / ) // // DBE Collectibles
/ ) /--< o // // http://www.wgn.net/~dbe/
-/-' /___/_<_</_</_ Email: dbe AT wgn DOT net
-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request AT cygnus DOT com" with one line of text: "help".
- Raw text -