After solve the problem with pthread and nanosleep (change the
parts/time.h header on MinGW and change config.h, in gnustep base, to
don't use nanosleep) I have other problem. The configure script now
defines HAVE_MKSTEMP to 1, used in -writeToFile:options:error: in
NSData. This part of code isn't mingw compatible, so I add some changes
(see attached patch). However a simple test fail. This program:
NSData *dat = [NSData dataWithContentsOfFile:
@"/MinGW/msys/home/German/src.txt"];
[dat writeToFile: @"c:/MinGW/msys/home/German/test.txt" atomically:
YES];
Always wrote the temporary file at current directory. So the NSData
object can't rename this later. What I'm doing wrong? Or is this a bug
on Base?
Thanks.
Germán
Index: Source/NSData.m
===================================================================
--- Source/NSData.m (revisión: 38334)
+++ Source/NSData.m (copia de trabajo)
@@ -1357,6 +1357,16 @@
int desc;
int mask;
+#if defined(__MINGW__)
+ strncpy(wthePath, wtheRealPath, sizeof(wthePath) - 1);
+ wthePath[sizeof(wthePath) - 1] = '\0';
+ strncat(wthePath, "XXXXXX", 6);
+ if ((desc = mkstemp(wthePath)) < 0)
+ {
+ NSWarnMLog(@"mkstemp (%s) failed - %@", wthePath, [NSError _last]);
+ goto failure;
+ }
+#else
strncpy(thePath, theRealPath, sizeof(thePath) - 1);
thePath[sizeof(thePath) - 1] = '\0';
strncat(thePath, "XXXXXX", 6);
@@ -1365,9 +1375,14 @@
NSWarnMLog(@"mkstemp (%s) failed - %@", thePath, [NSError _last]);
goto failure;
}
+#endif
mask = umask(0);
umask(mask);
+#if defined(__MINGW__)
+ chmod(wthePath, 0644 & ~mask);
+#else
fchmod(desc, 0644 & ~mask);
+#endif
if ((theFile = fdopen(desc, "w")) == 0)
{
close(desc);
@@ -1375,9 +1390,15 @@
}
else
{
+#if defined(__MINGW__)
+ strncpy(wthePath, wtheRealPath, sizeof(wthePath) - 1);
+ wthePath[sizeof(wthePath) - 1] = '\0';
+ theFile = fopen(wthePath, "wb");
+#else
strncpy(thePath, theRealPath, sizeof(thePath) - 1);
thePath[sizeof(thePath) - 1] = '\0';
theFile = fopen(thePath, "wb");
+#endif
}
#else
if (useAuxiliaryFile)
_______________________________________________
Gnustep-dev mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/gnustep-dev