bug-gnustep
[Top][All Lists]
Advanced

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

Re: NSFileManager.m (mingw): changeAttributes


From: Michael Scheibler
Subject: Re: NSFileManager.m (mingw): changeAttributes
Date: Fri, 23 Mar 2001 14:32:24 +0100

Michael Scheibler wrote:
>
> 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;


        // You could just insert these lines here so directories are
skipped:
        else if (sb.st_mode & _S_IFDIR)
          {
            ok = YES;
          }


>       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);
>         }
>     }
>
>
>
>
> _______________________________________________
> Bug-gnustep mailing list
> Bug-gnustep@gnu.org
> http://mail.gnu.org/mailman/listinfo/bug-gnustep
>




reply via email to

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