Thread overview
[Issue 7819] New: std.file.setTimes throws error on folders
Apr 04, 2012
Jay Norwood
Apr 05, 2012
Jay Norwood
Feb 10, 2013
Andrej Mitrovic
Feb 10, 2013
Andrej Mitrovic
April 04, 2012
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


--- Comment #0 from Jay Norwood <jayn@prismnet.com> 2012-04-04 05:42:30 PDT ---
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: -------
April 05, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7819



--- Comment #1 from Jay Norwood <jayn@prismnet.com> 2012-04-04 21:27:09 PDT ---
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: -------
February 10, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=7819


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

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


--- Comment #3 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2013-02-09 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: -------
February 10, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=7819



--- Comment #4 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2013-02-09 19:22:19 PST ---
(In reply to comment #3)
> 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: -------
February 10, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=7819



--- Comment #5 from github-bugzilla@puremagic.com 2013-02-10 15:42:54 PST ---
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 Merge pull request #1128 from AndrejMitrovic/Fix7819

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: -------
February 10, 2013
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: -------
February 13, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=7819



--- Comment #6 from github-bugzilla@puremagic.com 2013-02-13 00:14:10 PST ---
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: -------