sorry, I replied to Scott's mail not using "reply-all" (this ml-setting
sucks bigtime), so you only git half of the information.

On Sun, Mar 6, 2016 at 1:26 PM, Michael Hall <mik3h...@gmail.com> wrote:

> On Mar 6, 2016, at 5:28 AM, Robert Krüger <krue...@lesspain.de> wrote:
>
>
>
> On Sat, Mar 5, 2016 at 3:23 PM, Michael Hall <mik3h...@gmail.com> wrote:
>
>> On Mar 5, 2016, at 7:15 AM, Robert Krüger <krue...@lesspain.de> wrote:
>>
>>
>>
>> This…,
>>
>> https://stackoverflow.com/questions/9198184/setting-file-creation-timestamp-in-java
>> seems to suggest that File.setLastModified will accomplish what you wan
>> on OS Xt.
>>
>
> No, that's what I started with and it does what it's documented to do.
>
>
> I’m assuming ‘what it’s documented to do’ means it changes something other
> than finder creation date/time.
>

meaning it only changes last modified and not created.

When I set creation date using a cocoa call
(NSFileManager:setAttributes:ofItemAtPath:error:) mapped to java, behaviour
is as expected and creation date is changed. I filed a jdk bug report
(Review ID: JI-9031479).


>
> Maybe the stack overflow link I posted wasn’t concerned with changing
> Finder related.
> These suggest using the ‘touch’ or ‘SetFile’ commands could accomplish
> this...
>
> https://medium.com/@danilosapad/how-to-change-a-file-s-last-modified-and-creation-dates-on-mac-os-x-494f8f76cdf4#.y8qxzwtgg
>
> https://apple.stackexchange.com/questions/99536/changing-creation-date-of-a-file
> you could probably runtime exec those from java easily enough.
>
> Changing even from native seems like it could be a little tricky for some
> reason. At least this link suggests it might be...
>
> https://stackoverflow.com/questions/6905503/setting-nsfilecreationdate-has-no-effect
>
> My trz code does support some cocoa/NSFileManager type attributes…
>
> https://github.com/mik3hall/trz/blob/master/src/us/hall/trz/osx/test/MacAttributesTest.java
> shows junit tests of some of the api’s supported.
> For Cocoa it has this.
>
> @Test
> public void testCocoa() {
> try {
> File f = new File("build.xml");
> Path p = f.toPath();
> Map<String,Object> attrs = Files.readAttributes(p,"mac_cocoa:*");
> assertEquals(17,attrs.size());
>
> assertFalse(((Boolean)Files.getAttribute(p,"mac_cocoa:NSFileBusy")).booleanValue());
>
> assertEquals(Files.size(p),((Long)Files.getAttribute(p,"mac_cocoa:NSFileSize")).longValue());
>
> attrs = 
> Files.readAttributes(p,"mac_cocoa:NSFileModificationDate,mac_cocoa:NSFilePosixPermissions");
> assertEquals(2,attrs.size());
> }
> catch (IOException ioex) { fail(ioex.toString()); }
> }
>
> Updating may not be supported. But could be added if you or anyone else
> want to use it. I didn’t want
>

see above. It is supported by just creating a mutable dictionary with the
old values, mofiying the key for created date and then setting those
attributes.


> my first feedback on the code to be that someone tried it and something
> got messed up on their machine. “Hey, I tried your code and it turned all
> the files orange”. (I think I did include that possibility for FinderInfo
> though…
> Files.setAttribute(p, "mac_finder:label", "orange”);
> it was just kind of fun).
> This would do all the native for you and allow you to do what you want in
> the nio.2 way. Assuming I can get it to work. Despite the last stack
> overflow post it doesn’t seem like it should be all that difficult.
>
>
> Robert

Reply via email to