Bugzilla – Bug 4543
Function to get a file timestamp.
Last modified: 2014-02-08 23:52:09 PST
Created attachment 2267 [details] Example plugin for server clean up port. I know this is kind of late in the game for AMX Mod X but I was tasked with porting over my SM plugin server clean up to it. http://forums.alliedmods.net/showthread.php?p=1023928 Now I have the plugin done, but the problem is I need a function to get a file timestamp like SM but of course there is not one for AMX Mod X! I don't even know if this is really possible, I gather it probably is but I'd rather it be in the program itself vs me just packaging a module with my plugin just for this sole function. I'll admit I am terrible at any kind of low level stuff so I would need someone to patch it in for me, or I guess if you don't mind this staying open for a while whilst I learn, hah. Much thanks.
I'm willing to port it from Sourcemod as it's definitely useful.
I forgot I posted this, go right ahead if that's ok with you!
Created attachment 3381 [details] Proposed patch Would it be interesting to have another param to choose if you want the returned value in seconds/minutes/hours/weeks/months/years ?
Comment on attachment 3381 [details] Proposed patch Return should always be in seconds from epoch (unixtime). The patch is ok
What do you think adding another native but this time to get a file age ? Here an example of header : enum FileTimeFormat { TimeFormat_Second, TimeFormat_Hour, TimeFormat_Day, TimeFormat_Week, TimeFormat_Month, TimeFormat_Year }; GetFileAge( const file[], FileTimeType:tmode, FileTimeFormat:tformat = TimeFormat_Second ); I see this useful for example, pruning log files created <= 30 days. It would be more convenient and avoid extra natives uses. Both natives would have own purposes.
That would be great, it's totally up to everyone else in development though if it would be useful elsewhere as I am easy doing it either way.
date/time functions should be within date/time functions. Just let this function return some standard format and then you can convert it with date/time functions.
Pushed changeset: http://hg.alliedmods.net/amxmodx-central/rev/3bcba0ef360b Changelog: Add GetFileTime returning a file timestamp as a unix timestamp (bug 4543, r=joropito)
Thanks for adding it! Seems to work fine apart from there's a spelling mistake in file.inc, line 148 has "FileTime_LastChang", missing the "e" on the end! I hope I picked the appropriate status!
Ah, sorry for double post, but essentially it won't compile the plugin if you actually use FileTime_LastChange.
Oops, did not see your message. Damn typo. Will fix that.
Created attachment 3403 [details] Proposed patch to fix typo It has been fixed. It will be available the next time I push a bunch of changes. Meanwhile, you can do the trick with 'FileTimeType:2' .
Commit pushed to master at https://github.com/alliedmodders/amxmodx https://github.com/alliedmodders/amxmodx/commit/e5864c5abf1051ac7254c7d62a16604c98041737 Add GetFileTime returning a file timestamp as a unix timestamp (bug 4543, r=joropito) Former-commit-id: cf7b8645fa6a14e5be71336df4543901b2c53e0b