Bug 4543 - Function to get a file timestamp.
Function to get a file timestamp.
Status: RESOLVED FIXED
Product: AMX Mod X
Classification: Unclassified
Component: Module: Engine
trunk
PC All
: P3 enhancement
Assigned To: amxmodx-bugs@alliedmods.net
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2010-07-26 08:54 PDT by Jamster
Modified: 2014-02-08 23:52 PST (History)
4 users (show)

See Also:


Attachments
Example plugin for server clean up port. (6.04 KB, application/octet-stream)
2010-07-26 08:54 PDT, Jamster
no flags Details
Proposed patch (2.16 KB, text/plain)
2013-06-20 16:00 PDT, Vincent Herbet [:Arkshine]
hv.contact: review+
joropito: feedback+
Details
Proposed patch to fix typo (447 bytes, text/plain)
2013-06-29 03:36 PDT, Vincent Herbet [:Arkshine]
hv.contact: review+
Details

Description Jamster 2010-07-26 08:54:40 PDT
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.
Comment 1 Vincent Herbet [:Arkshine] 2013-06-18 03:59:39 PDT
I'm willing to port it from Sourcemod as it's definitely useful.
Comment 2 Jamster 2013-06-18 05:49:28 PDT
I forgot I posted this, go right ahead if that's ok with you!
Comment 3 Vincent Herbet [:Arkshine] 2013-06-20 16:00:14 PDT
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 4 joropito 2013-06-20 20:43:50 PDT
Comment on attachment 3381 [details]
Proposed patch

Return should always be in seconds from epoch (unixtime).
The patch is ok
Comment 5 Vincent Herbet [:Arkshine] 2013-06-21 02:25:48 PDT
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.
Comment 6 Jamster 2013-06-21 04:33:18 PDT
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.
Comment 7 joropito 2013-06-21 08:08:53 PDT
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.
Comment 8 Vincent Herbet [:Arkshine] 2013-06-25 07:59:42 PDT
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)
Comment 9 Jamster 2013-06-25 11:37:56 PDT
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!
Comment 10 Jamster 2013-06-25 11:39:48 PDT
Ah, sorry for double post, but essentially it won't compile the plugin if you actually use FileTime_LastChange.
Comment 11 Vincent Herbet [:Arkshine] 2013-06-29 03:30:38 PDT
Oops, did not see your message.

Damn typo. Will fix that.
Comment 12 Vincent Herbet [:Arkshine] 2013-06-29 03:36:45 PDT
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' .
Comment 13 AM Bugzilla Bot 2014-02-08 23:52:09 PST
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

Note You need to log in before you can comment on or make changes to this bug.