bug-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSFileManager.m (mingw): changeAttributes


From: Michael Scheibler
Subject: NSFileManager.m (mingw): changeAttributes
Date: Fri, 23 Mar 2001 09:07:04 +0100

When I use NSFileManager's copyPath: toPath: handler: to copy a directory,
it returns with a NO. The problem lies in changeFileAttributes: atPath:
The function utime() is used to set the last modification time, but on
Windows directories don't have a modification time. So this always results
in an error.


  date = [attributes objectForKey: NSFileModificationDate];
  if (date)
    {
      BOOL ok = NO;
      struct stat sb;
#if  defined(__WIN32__) || defined(_POSIX_VERSION)
      struct utimbuf ub;
#else
      time_t ub[2];
#endif

      if (stat(cpath, &sb) != 0)
        ok = NO;
      else
        {
#if  defined(__WIN32__) || defined(_POSIX_VERSION)
          ub.actime = sb.st_atime;
          ub.modtime = [date timeIntervalSince1970];
          ok = (utime(cpath, &ub) == 0);     // <-- Here is the error
                                             //     It sets errno=EACCES
                                             //     when used on directories
                                             //     or read-only files
#else
          ub[0] = sb.st_atime;
          ub[1] = [date timeIntervalSince1970];
          ok = (utime((char*)cpath, ub) == 0);
#endif
        }
      if (ok == NO)
        {
          allOk = NO;
          str = [NSString stringWithFormat:
                  @"Unable to change NSFileModificationDate to '%@'", date];
          ASSIGN(_lastError, str);
        }
    }






reply via email to

[Prev in Thread] Current Thread [Next in Thread]