Home Download Buy Blog Forum Support

Plugin and keep filename up to date

Plugin and keep filename up to date

Postby Xaelias on Mon Oct 07, 2013 11:00 pm


I have been looking for a plugin able to insert/update at the beginning of files the date of creation and date of last modification as a comment. Apparently I didn't find anything like this that already exists (if you have, please tell me, it can't be worst than what I've been doing).
Anyway, I gave up and did something myself. And the output is something like this:
Code: Select all

   Owner         = Xaelias
   Created       = ``2013-10-07 15:48:45''
   Last modified = ``2013-10-07 16:52:48''

It is more or less what I want to have, so no issue there.
But I would like to also keep to date the filename. For now, I put all the code in one function called on_pre_save. What I would like is, if the file is renamed in the OS, and then saved again in ST(3), update the filename, and if the file is saved as a copy under another name is ST, update that field too.

Fro now, I guess the easiest way to do that would be to update that field on_post_save, which would be a pain in the rear for me right now for two reasons:
- first I would have to rewrite a part of it (not so bad I guess ^^)
- second, of course, as intended, it would modify the file AFTER it has been saved. So, I would have to save it a second time.

So I have two questions, to avoid my frist issue, is it possible to get the name of the file before it is actualy saved (so if the file is not yet saved on the hard drive, get the name after the prompt for the name has been answered, and tor a copy, the new name)?
If not, on_post_save, is it possible to save the file without triggering on_pre_save and on_post_save?

Thank you very much
Posts: 1
Joined: Mon Oct 07, 2013 10:49 pm

Return to Plugin Development

Who is online

Users browsing this forum: No registered users and 4 guests