add filesep & pathsep functions
Allan Cornet [Tue, 24 Jul 2007 09:49:53 +0000 (09:49 +0000)]
scilab/modules/fileio/Makefile.am
scilab/modules/fileio/fileio.vcproj
scilab/modules/fileio/help/en_US/filesep.xml [new file with mode: 0644]
scilab/modules/fileio/help/en_US/pathsep.xml [new file with mode: 0644]
scilab/modules/fileio/includes/gw_fileio.h
scilab/modules/fileio/sci_gateway/c/gw_fileio.c
scilab/modules/fileio/sci_gateway/c/sci_filesep.c [new file with mode: 0644]
scilab/modules/fileio/sci_gateway/c/sci_pathsep.c [new file with mode: 0644]
scilab/modules/fileio/sci_gateway/fileio_gateway.xml

index 07b26af..1f95dff 100644 (file)
@@ -58,7 +58,9 @@ sci_gateway/c/sci_findfiles.c \
 sci_gateway/c/sci_maxfiles.c \
 sci_gateway/c/sci_getdrives.c \
 sci_gateway/c/sci_fullpath.c \
-sci_gateway/c/sci_deletefile.c
+sci_gateway/c/sci_deletefile.c \
+sci_gateway/c/sci_pathsep.c \
+sci_gateway/c/sci_filesep.c
 
 libscifileio_la_CFLAGS=-Iincludes/ -Isrc/c/ -I$(top_srcdir)/libs/MALLOC/includes/ 
 
index bb3cabc..a6abc53 100644 (file)
                                >
                        </File>
                        <File
+                               RelativePath=".\sci_gateway\c\sci_filesep.c"
+                               >
+                       </File>
+                       <File
                                RelativePath=".\sci_gateway\c\sci_findfiles.c"
                                >
                        </File>
                                >
                        </File>
                        <File
+                               RelativePath=".\sci_gateway\c\sci_pathsep.c"
+                               >
+                       </File>
+                       <File
                                RelativePath=".\sci_gateway\c\sci_xls_open.c"
                                >
                        </File>
diff --git a/scilab/modules/fileio/help/en_US/filesep.xml b/scilab/modules/fileio/help/en_US/filesep.xml
new file mode 100644 (file)
index 0000000..49cc09b
--- /dev/null
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE MAN SYSTEM "../../../../modules/helptools/help.dtd">
+<MAN>
+  <LANGUAGE>eng</LANGUAGE>
+
+  <TITLE>filesep</TITLE>
+
+  <TYPE>Scilab Function</TYPE>
+
+  <DATE>$LastChangedDate: 2006-09-10 20:58:00 +0200 (dim., 10 sept. 2006)$</DATE>
+
+  <SHORT_DESCRIPTION name="filesep">returns directory separator for current platform</SHORT_DESCRIPTION>
+
+  <CALLING_SEQUENCE>
+    <CALLING_SEQUENCE_ITEM>s = filesep()</CALLING_SEQUENCE_ITEM>
+  </CALLING_SEQUENCE>
+
+  <PARAM>
+    <PARAM_INDENT>
+      <PARAM_ITEM>
+        <PARAM_NAME>s</PARAM_NAME>
+
+        <PARAM_DESCRIPTION>
+          <SP>: a string</SP>
+        </PARAM_DESCRIPTION>
+      </PARAM_ITEM>
+    </PARAM_INDENT>
+  </PARAM>
+
+  <DESCRIPTION>
+    <P>returns directory separator. ( '/' on Linux or '\' on Windows )</P>
+  </DESCRIPTION>
+
+  <EXAMPLE><![CDATA[filesep()]]></EXAMPLE>
+
+  <AUTHORS>
+    <AUTHORS_ITEM>A.C</AUTHORS_ITEM>
+  </AUTHORS>
+</MAN>
\ No newline at end of file
diff --git a/scilab/modules/fileio/help/en_US/pathsep.xml b/scilab/modules/fileio/help/en_US/pathsep.xml
new file mode 100644 (file)
index 0000000..3dcfc90
--- /dev/null
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE MAN SYSTEM "../../../../modules/helptools/help.dtd">
+<MAN>
+  <LANGUAGE>eng</LANGUAGE>
+
+  <TITLE>pathsep</TITLE>
+
+  <TYPE>Scilab Function</TYPE>
+
+  <DATE>$LastChangedDate: 2006-09-10 20:58:00 +0200 (dim., 10 sept. 2006)$</DATE>
+
+  <SHORT_DESCRIPTION name="pathsep">returns path separator for current platform</SHORT_DESCRIPTION>
+
+  <CALLING_SEQUENCE>
+    <CALLING_SEQUENCE_ITEM>s = pathsep()</CALLING_SEQUENCE_ITEM>
+  </CALLING_SEQUENCE>
+
+  <PARAM>
+    <PARAM_INDENT>
+      <PARAM_ITEM>
+        <PARAM_NAME>s</PARAM_NAME>
+
+        <PARAM_DESCRIPTION>
+          <SP>: a string</SP>
+        </PARAM_DESCRIPTION>
+      </PARAM_ITEM>
+    </PARAM_INDENT>
+  </PARAM>
+
+  <DESCRIPTION>
+    <P>returns path separator. ( ':' on Linux or ';' on Windows )</P>
+  </DESCRIPTION>
+
+  <EXAMPLE><![CDATA[pathsep()]]></EXAMPLE>
+
+  <AUTHORS>
+    <AUTHORS_ITEM>A.C</AUTHORS_ITEM>
+  </AUTHORS>
+</MAN>
\ No newline at end of file
index 125b05c..fc4b322 100644 (file)
@@ -39,6 +39,8 @@ int C2F(sci_maxfiles) _PARAMS((char *fname,unsigned long fname_len));
 int C2F(sci_getdrives) _PARAMS((char *fname,unsigned long fname_len));
 int C2F(sci_fullpath) _PARAMS((char *fname,unsigned long fname_len));
 int C2F(sci_deletefile) _PARAMS((char *fname,unsigned long fname_len));
+int C2F(sci_pathsep) _PARAMS((char *fname,unsigned long fname_len));
+int C2F(sci_filesep) _PARAMS((char *fname,unsigned long fname_len));
 /*-----------------------------------------------------------------------------------*/ 
 #endif /* __GW_FILEIO_H__ */
 /*-----------------------------------------------------------------------------------*/
index b90d252..484dac0 100644 (file)
@@ -35,7 +35,9 @@ static gw_generic_table Tab[]={
        {C2F(sci_maxfiles),"maxfiles"},
        {C2F(sci_getdrives),"getdrives"},
        {C2F(sci_fullpath),"fullpath"},
-       {C2F(sci_deletefile),"deletefile"}
+       {C2F(sci_deletefile),"deletefile"},
+       {C2F(sci_pathsep),"pathsep"},
+       {C2F(sci_filesep),"filesep"}
        };
 /*-----------------------------------------------------------------------------------*/ 
 int C2F(gw_fileio)(void)
diff --git a/scilab/modules/fileio/sci_gateway/c/sci_filesep.c b/scilab/modules/fileio/sci_gateway/c/sci_filesep.c
new file mode 100644 (file)
index 0000000..0185abd
--- /dev/null
@@ -0,0 +1,31 @@
+/*-----------------------------------------------------------------------------------*/\r
+/* INRIA 2007 */\r
+/* Allan CORNET */\r
+/*-----------------------------------------------------------------------------------*/\r
+#include "gw_fileio.h"\r
+#include "stack-c.h"\r
+#include "MALLOC.h"\r
+#include "Scierror.h"\r
+/*-----------------------------------------------------------------------------------*/\r
+int C2F(sci_filesep) _PARAMS((char *fname,unsigned long fname_len))\r
+{\r
+       static int n1,m1;\r
+       char *separator=NULL;\r
+\r
+       CheckRhs(0,0);\r
+       CheckLhs(1,1);\r
+\r
+       separator=(char*)MALLOC(sizeof(char)*(strlen(DIR_SEPARATOR)+1));\r
+       if (separator) strcpy(separator,DIR_SEPARATOR);\r
+\r
+       n1 = 1;\r
+       CreateVarFromPtr(Rhs+1, "c",(m1=(int)strlen(separator), &m1),&n1,&separator);\r
+       LhsVar(1)=Rhs+1;\r
+       C2F(putlhsvar)();\r
+\r
+       if (separator) {FREE(separator);separator=NULL;}\r
+\r
+       return 0;\r
+}\r
+/*-----------------------------------------------------------------------------------*/\r
+\r
diff --git a/scilab/modules/fileio/sci_gateway/c/sci_pathsep.c b/scilab/modules/fileio/sci_gateway/c/sci_pathsep.c
new file mode 100644 (file)
index 0000000..4dabf79
--- /dev/null
@@ -0,0 +1,30 @@
+/*-----------------------------------------------------------------------------------*/\r
+/* INRIA 2007 */\r
+/* Allan CORNET */\r
+/*-----------------------------------------------------------------------------------*/\r
+#include "gw_fileio.h"\r
+#include "stack-c.h"\r
+#include "MALLOC.h"\r
+#include "Scierror.h"\r
+/*-----------------------------------------------------------------------------------*/\r
+int C2F(sci_pathsep) _PARAMS((char *fname,unsigned long fname_len))\r
+{\r
+       static int n1,m1;\r
+       char *separator=NULL;\r
+\r
+       CheckRhs(0,0);\r
+       CheckLhs(1,1);\r
+\r
+       separator=(char*)MALLOC(sizeof(char)*(strlen(PATH_SEPARATOR)+1));\r
+       if (separator) strcpy(separator,PATH_SEPARATOR);\r
+       \r
+       n1 = 1;\r
+       CreateVarFromPtr(Rhs+1, "c",(m1=(int)strlen(separator), &m1),&n1,&separator);\r
+       LhsVar(1)=Rhs+1;\r
+       C2F(putlhsvar)();\r
+\r
+       if (separator) {FREE(separator);separator=NULL;}\r
+\r
+       return 0;\r
+}\r
+/*-----------------------------------------------------------------------------------*/\r
index f477521..2bcebd2 100644 (file)
@@ -51,4 +51,6 @@
 <PRIMITIVE gatewayId="34" primitiveId="25" primitiveName="getdrives" />
 <PRIMITIVE gatewayId="34" primitiveId="26" primitiveName="fullpath" />
 <PRIMITIVE gatewayId="34" primitiveId="27" primitiveName="deletefile" />
+<PRIMITIVE gatewayId="34" primitiveId="28" primitiveName="pathsep"/>
+<PRIMITIVE gatewayId="34" primitiveId="29" primitiveName="filesep"/>
 </GATEWAY>