www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 7819] New: std.file.setTimes throws error on folders

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7819

           Summary: std.file.setTimes throws error on folders
           Product: D
           Version: D2
          Platform: x86
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: nobody puremagic.com
        ReportedBy: jayn prismnet.com



std.file.setTimes threw an error on folder names while it worked ok on regular
files.  Not sure if it is an error since there is no documentation that it
shouldn't work for folders.  Should it work, or what is the alternative?

In the lines below, am.time was from std.zip archive entry.
tz was from localTime().
fullPathname is a full path to a windows directory name.

SysTime st = DosFileTimeToSysTime(am.time, tz);
std.file.setTimes(fullPathname, st, st);

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Apr 04 2012
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7819




It looks like CreateFile requires a special flag, FILE_FLAG_BACKUP_SEMANTICS , 
in order to get a handle from a directory that can be used with the SetFileTime
call. Below is an excerpt from a discussion on the topic.

http://cygwin.com/ml/cygwin/1997-12/msg00350.html

Windows NT: You can obtain a handle to a directory by calling the
CreateFile function with the FILE_FLAG_BACKUP_SEMANTICS flag set, as
follows:
hDir = CreateFile (
    DirName,
    GENERIC_READ,
    FILE_SHARE_READ|FILE_SHARE_DELETE,
    NULL,
    OPEN_EXISTING,
    FILE_FLAG_BACKUP_SEMANTICS,
    NULL
);

You can pass a directory handle to the following SetFileTime function.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Apr 04 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7819


Andrej Mitrovic <andrej.mitrovich gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull



19:21:27 PST ---
https://github.com/D-Programming-Language/phobos/pull/1128

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 09 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7819




19:22:19 PST ---

 https://github.com/D-Programming-Language/phobos/pull/1128
Thanks for the patch Jay Norwood! -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Feb 09 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7819




Commits pushed to master at https://github.com/D-Programming-Language/phobos

https://github.com/D-Programming-Language/phobos/commit/26edcdd305b25c3fae7fdf54ebe9768a554c9aa8
Fixes Issue 7819 - setTimes should work on folders.

https://github.com/D-Programming-Language/phobos/commit/ad80aef23e54a9f9b4eec32e21016365b7b0f9b4


Issue 7819 - setTimes should support folders on Windows

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 10 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7819


Alex Rønne Petersen <alex lycus.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |alex lycus.org
         Resolution|                            |FIXED


-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 10 2013
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7819




Commit pushed to staging at https://github.com/D-Programming-Language/phobos

https://github.com/D-Programming-Language/phobos/commit/dc32bd2595d2dfcd7b1f50375a80fd58307fd8dc
Fixes Issue 7819 - setTimes should work on folders.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 13 2013