Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LuaMacro plugin: Enable win.GetFileTimes/win.SetFileTimes to get/set change time #611

Open
rohitab opened this issue Jan 21, 2023 · 7 comments

Comments

@rohitab
Copy link
Contributor

rohitab commented Jan 21, 2023

Description of the new feature or improvement

The Lua function win.GetFileTimes returns Creation time, Last access time, and Last write time as shown in the following code. It does not return Change time.

if (GetFileTime(hFile, &t_create, &t_access, &t_write))
{
lua_createtable(L, 0, 3);
PutFileTimeToTableEx(L, &t_create, "CreationTime");
PutFileTimeToTableEx(L, &t_access, "LastAccessTime");
PutFileTimeToTableEx(L, &t_write, "LastWriteTime");
res = 1;
}

Similarly, win.SetFileTimes sets the same time values as shown in the following code. It does not set Change time.

if (ExtractFileTime(L, "CreationTime", &t_create, hFile))
p_create = &t_create;
if (ExtractFileTime(L, "LastAccessTime", &t_access, hFile))
p_access = &t_access;
if (ExtractFileTime(L, "LastWriteTime", &t_write, hFile))
p_write = &t_write;
lua_pushboolean(L, (p_create||p_access||p_write) && SetFileTime(hFile,p_create,p_access,p_write));

Could you please add support for getting and setting Change time as well? This would allow Lua macros to set and restore all file times, similar to the Preserve all timestamps feature in the Copy and Rename/Move dialogs.

Proposed technical implementation details (optional)

Use file::GetTime and file::SetTime instead of GetFileTime and SetFileTime respectively.

bool GetTime(chrono::time_point* CreationTime, chrono::time_point* LastAccessTime, chrono::time_point* LastWriteTime, chrono::time_point* ChangeTime) const;
bool SetTime(const chrono::time_point* CreationTime, const chrono::time_point* LastAccessTime, const chrono::time_point* LastWriteTime, const chrono::time_point* ChangeTime) const;

@johnd0e
Copy link
Contributor

johnd0e commented Jul 21, 2023

@shmuz

@shmuz
Copy link
Contributor

shmuz commented Jul 21, 2023

@johnd0e, as you know I'm spending all my spare time nowadays on far2m, etc. and there's no ChangeTime there.

@johnd0e
Copy link
Contributor

johnd0e commented Jul 21, 2023

@shmuz, yes I know.
But still hope that some day you will be able to find some time.
Or at least give us your opinion about proposed implementation.

@shmuz
Copy link
Contributor

shmuz commented Jul 21, 2023

  1. It's not a proposed implementation here, it is just a suggestion to use the same code Far3 uses.
  2. I respect you being a Far3 "patriot", but on the other hand you could help me a lot with far2m but you won't do that.

@johnd0e
Copy link
Contributor

johnd0e commented Jul 21, 2023

you could help me a lot with far2m but you won't do that.

I will be happy to help where I can.
At the moment I have no system where I could run far2m.

@rohitab
Copy link
Contributor Author

rohitab commented Jul 22, 2023

@johnd0e Thank you for trying to get this issue resolved.

  1. It's not a proposed implementation here, it is just a suggestion to use the same code Far3 uses.

@shmuz The suggestion and the proposed implementation are the same, i.e. to use different functions, ones that get/set 4 file times instead of 3. I'd be happy to submit a patch if someone can review and commit it.

@shmuz
Copy link
Contributor

shmuz commented Jul 22, 2023

@rohitab

I'd be happy to submit a patch if someone can review and commit it.

It seems to be the right way. It won't guarantee immediate review and commit but the chances would be much higher.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants