"modified date" info plugin,
- From: Muthiah Annamalai <muthus_post yahoo com>
- To: gnumeric list <gnumeric-list lists gnome org>
- Cc:
- Subject: "modified date" info plugin,
- Date: Fri, 3 Feb 2006 17:05:56 -0800 (PST)
Hi,
I have created a patch for the modified date function as a plugin into
the fn-info/ tree of Gnumeric source.
You can use to access the modified, created and accessed times of the
current file. It work on Unix only.
Patch is below.
Muthu
Index: ./plugins/fn-info/ChangeLog
===================================================================
RCS file: /cvs/gnome/gnumeric/plugins/fn-info/ChangeLog,v
retrieving revision 1.71
diff -r1.71 ChangeLog
0a1,5
> 2006-02-03 Muthiah Annamalai <muthiah annamalai uta edu>
> * functions.c: Added new function 'fileinfo' to
> add the modified,changed, created dates from cell.
> works only on Unix, AFAIK.
>
Index: ./plugins/fn-info/functions.c
===================================================================
RCS file: /cvs/gnome/gnumeric/plugins/fn-info/functions.
c,v
retrieving revision 1.159
diff -r1.159 functions.c
59a60,71
> #include <time.h>
>
>
> #include <glib/gstrfuncs.h>
>
> #ifndef G_OS_WIN32
> #include <sys/types.h>
> #include <sys/stat.h>
> #include <unistd.h>
> #endif
>
>
1877a1890,1955
> /***************************************************************************/
>
> static GnmFuncHelp const help_fileinfo[] = {
> { GNM_FUNC_HELP_OLD,
> F_("@FUNCTION=FILEINFO\n"
> "@SYNTAX=FILEINFO(string)\n"
>
> "@DESCRIPTION="
> "FILEINFO retrieves a property of the worksheet file."
> "By default if you donot pass any argument, it returns the.\n"
>
"full file path name. \n"
> "* The @string can be any of the following:"
> "'modified' returns the last modified date.\n"
> "'created' returns the creation date.\n"
> "'access' returns last last access date.\n"
> "'size' returns file size in bytes on last save.\n"
> "'file'return the filename by default.\n"
> "Note: These functions are UNIX specific.\n"
> "Windows users can only get the value of filename/uri\n"
> "on using this function. Any other function call will\n"
> "result in an error\n"
> "@EXAMPLES=\n"
>
"FILEINFO(\"modified\")=\"Fri Feb 3 13:42:15 CST 2006\"\n"
> "@SEEALSO=")
> },
> { GNM_FUNC_HELP_END }
> };
>
> static GnmValue *
> gnumeric_fileinfo (FunctionEvalInfo *ei, GnmValue const * const *argv)
> {
> char const *var = NULL;
>
> if (argv[0]){
>
> #ifndef G_OS_WIN32
> struct stat buf={0,};
> char const *uri = workbook_get_uri (ei->pos->sheet->workbook);
>
> var=value_get_as_string(argv[0]);
> if(stat(uri+sizeof("file:/"),&buf)!=0)
> re
turn
value_new_error_NA(0);
>
>
> if(!strcasecmp(var,"modified")){
> return value_new_string (ctime(&buf.st_mtime));
> }
> else if(!strcasecmp(var,"created")){
>
> return value_new_string(ctime(&buf.st_ctime));;
> }
> else if(!strcasecmp(var,"access")){
>
> return value_new_string(ctime(&(buf.st_atime)));
> }
> &nbs
p;
else if(!strcasecmp(var,"size")){
> return value_new_float(buf.st_size);
> }
> #endif
> //else, Implicit here.
> return value_new_string(ei->pos->sheet->name_unquoted);
> }
>
> //else, Implicit here.
> return value_new_string(workbook_get_uri(ei->pos->sheet->workbook));
> }
1948c2026,2028
<
---
> { "fileinfo", "|s", N_("string"), help_fileinfo,
> gnumeric_fileinfo, NULL, NULL, NULL, NULL,
> GNM_FUNC_SIMPLE, GNM_FUNC_IMPL_STATUS_UNIQUE_TO_GNUMERIC, GNM_FUNC_TEST_STATUS_NO_TESTSUITE },
Index: ./plugins/fn-info/plugin.xm
l.in
===================================================================
RCS file: /cvs/gnome/gnumeric/plugins/fn-info/plugin.xml.in,v
retrieving revision 1.4
diff -r1.4 plugin.xml.in
34a35
> <function name="fileinfo" />
Brings words and photos together (easily) with
PhotoMail - it's free and works with Yahoo! Mail.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]