remove getFullFilename from output_stream and use one in fileio 04/17204/3
Antoine ELIAS [Mon, 14 Sep 2015 10:31:53 +0000 (12:31 +0200)]
Change-Id: I51974b4a8346315f7a995cdd287c9ecaa07f5bb7

17 files changed:
scilab/modules/fileio/includes/getFullFilename.h
scilab/modules/fileio/src/c/getFullFilename.c
scilab/modules/output_stream/Makefile.am
scilab/modules/output_stream/Makefile.in
scilab/modules/output_stream/src/c/Fileio_Import.def [new file with mode: 0644]
scilab/modules/output_stream/src/c/output_stream.vcxproj
scilab/modules/output_stream/src/c/output_stream.vcxproj.filters
scilab/modules/output_stream/src/cpp/Diary.cpp
scilab/modules/output_stream/src/cpp/Diary.hxx
scilab/modules/output_stream/src/cpp/DiaryList.cpp
scilab/modules/output_stream/src/cpp/getFullFilename.cpp [deleted file]
scilab/modules/output_stream/src/cpp/getUniqueFilename.cpp [new file with mode: 0644]
scilab/modules/output_stream/src/cpp/getUniqueFilename.hxx [moved from scilab/modules/output_stream/src/cpp/getFullFilename.hxx with 75% similarity]
scilab/modules/output_stream/tests/nonreg_tests/bug_557.dia.ref
scilab/modules/output_stream/tests/nonreg_tests/bug_557.tst
scilab/modules/output_stream/tests/nonreg_tests/bug_9104.dia.ref
scilab/modules/output_stream/tests/nonreg_tests/bug_9104.tst

index 64f899d..d66a6ab 100644 (file)
 * @param[in] FilenameInput can be a relative path
 * @return a full filename (path expanded)
 */
-FILEIO_IMPEXP wchar_t *getFullFilenameW(wchar_t* FilenameInput);
+FILEIO_IMPEXP wchar_t* getFullFilenameW(const wchar_t* FilenameInput);
 
 /**
 * get full filename of a file
 * @param[in] FilenameInput can be a relative path
 * @return a full filename (path expanded)
 */
-FILEIO_IMPEXP char *getFullFilename(char* Filename);
+FILEIO_IMPEXP char* getFullFilename(const char* Filename);
 
 #endif /* __GETFULLFILENAME_H__ */
 /*--------------------------------------------------------------------------*/
index 4702f21..6dfa8c9 100644 (file)
@@ -19,7 +19,7 @@
 #include "isdir.h"
 #include "fullpath.h"
 /*--------------------------------------------------------------------------*/
-wchar_t *getFullFilenameW(wchar_t* FilenameInput)
+wchar_t *getFullFilenameW(const wchar_t* FilenameInput)
 {
     wchar_t *pStwcFullFilename = NULL;
 
@@ -118,7 +118,7 @@ wchar_t *getFullFilenameW(wchar_t* FilenameInput)
 
 }
 /*--------------------------------------------------------------------------*/
-char *getFullFilename(char* Filename)
+char *getFullFilename(const char* Filename)
 {
     char *pStFullFilename = NULL;
     if (Filename)
index 2766354..bb32c23 100644 (file)
@@ -15,7 +15,7 @@ OUTPUT_STREAM_CPP_SOURCES = \
        src/cpp/DiaryList.cpp \
        src/cpp/diary_manager.cpp \
        src/cpp/getDiaryDate.cpp \
-       src/cpp/getFullFilename.cpp \
+       src/cpp/getUniqueFilename.cpp \
        src/cpp/scilab_sprintf.cpp \
        src/cpp/basout.cpp
 
@@ -76,6 +76,7 @@ libscioutput_stream_la_CPPFLAGS= \
     -I$(top_srcdir)/modules/console/includes \
     -I$(top_srcdir)/modules/dynamic_link/includes \
     -I$(top_srcdir)/modules/localization/includes/ \
+    -I$(top_srcdir)/modules/fileio/includes/ \
     $(AM_CPPFLAGS)
 
 if MAINTAINER_MODE
index e2ba740..dfbbc0e 100644 (file)
@@ -196,7 +196,7 @@ am__objects_2 = src/cpp/libscioutput_stream_algo_la-Diary.lo \
        src/cpp/libscioutput_stream_algo_la-DiaryList.lo \
        src/cpp/libscioutput_stream_algo_la-diary_manager.lo \
        src/cpp/libscioutput_stream_algo_la-getDiaryDate.lo \
-       src/cpp/libscioutput_stream_algo_la-getFullFilename.lo \
+       src/cpp/libscioutput_stream_algo_la-getUniqueFilename.lo \
        src/cpp/libscioutput_stream_algo_la-scilab_sprintf.lo \
        src/cpp/libscioutput_stream_algo_la-basout.lo
 am__objects_3 = src/fortran/wspdsp.lo src/fortran/wmdsp.lo \
@@ -620,7 +620,7 @@ OUTPUT_STREAM_CPP_SOURCES = \
        src/cpp/DiaryList.cpp \
        src/cpp/diary_manager.cpp \
        src/cpp/getDiaryDate.cpp \
-       src/cpp/getFullFilename.cpp \
+       src/cpp/getUniqueFilename.cpp \
        src/cpp/scilab_sprintf.cpp \
        src/cpp/basout.cpp
 
@@ -679,6 +679,7 @@ libscioutput_stream_la_CPPFLAGS = \
     -I$(top_srcdir)/modules/console/includes \
     -I$(top_srcdir)/modules/dynamic_link/includes \
     -I$(top_srcdir)/modules/localization/includes/ \
+    -I$(top_srcdir)/modules/fileio/includes/ \
     $(AM_CPPFLAGS)
 
 @MAINTAINER_MODE_TRUE@pkglib_LTLIBRARIES = libscioutput_stream.la
@@ -915,7 +916,7 @@ src/cpp/libscioutput_stream_algo_la-diary_manager.lo:  \
        src/cpp/$(am__dirstamp) src/cpp/$(DEPDIR)/$(am__dirstamp)
 src/cpp/libscioutput_stream_algo_la-getDiaryDate.lo:  \
        src/cpp/$(am__dirstamp) src/cpp/$(DEPDIR)/$(am__dirstamp)
-src/cpp/libscioutput_stream_algo_la-getFullFilename.lo:  \
+src/cpp/libscioutput_stream_algo_la-getUniqueFilename.lo:  \
        src/cpp/$(am__dirstamp) src/cpp/$(DEPDIR)/$(am__dirstamp)
 src/cpp/libscioutput_stream_algo_la-scilab_sprintf.lo:  \
        src/cpp/$(am__dirstamp) src/cpp/$(DEPDIR)/$(am__dirstamp)
@@ -1017,7 +1018,7 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote@src/cpp/$(DEPDIR)/libscioutput_stream_algo_la-basout.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@src/cpp/$(DEPDIR)/libscioutput_stream_algo_la-diary_manager.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@src/cpp/$(DEPDIR)/libscioutput_stream_algo_la-getDiaryDate.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@src/cpp/$(DEPDIR)/libscioutput_stream_algo_la-getFullFilename.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/cpp/$(DEPDIR)/libscioutput_stream_algo_la-getUniqueFilename.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@src/cpp/$(DEPDIR)/libscioutput_stream_algo_la-scilabWrite.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@src/cpp/$(DEPDIR)/libscioutput_stream_algo_la-scilab_sprintf.Plo@am__quote@
 
@@ -1174,12 +1175,12 @@ src/cpp/libscioutput_stream_algo_la-getDiaryDate.lo: src/cpp/getDiaryDate.cpp
 @AMDEP_TRUE@@am__fastdepCXX_FALSE@     DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscioutput_stream_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o src/cpp/libscioutput_stream_algo_la-getDiaryDate.lo `test -f 'src/cpp/getDiaryDate.cpp' || echo '$(srcdir)/'`src/cpp/getDiaryDate.cpp
 
-src/cpp/libscioutput_stream_algo_la-getFullFilename.lo: src/cpp/getFullFilename.cpp
-@am__fastdepCXX_TRUE@  $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscioutput_stream_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT src/cpp/libscioutput_stream_algo_la-getFullFilename.lo -MD -MP -MF src/cpp/$(DEPDIR)/libscioutput_stream_algo_la-getFullFilename.Tpo -c -o src/cpp/libscioutput_stream_algo_la-getFullFilename.lo `test -f 'src/cpp/getFullFilename.cpp' || echo '$(srcdir)/'`src/cpp/getFullFilename.cpp
-@am__fastdepCXX_TRUE@  $(AM_V_at)$(am__mv) src/cpp/$(DEPDIR)/libscioutput_stream_algo_la-getFullFilename.Tpo src/cpp/$(DEPDIR)/libscioutput_stream_algo_la-getFullFilename.Plo
-@AMDEP_TRUE@@am__fastdepCXX_FALSE@     $(AM_V_CXX)source='src/cpp/getFullFilename.cpp' object='src/cpp/libscioutput_stream_algo_la-getFullFilename.lo' libtool=yes @AMDEPBACKSLASH@
+src/cpp/libscioutput_stream_algo_la-getUniqueFilename.lo: src/cpp/getUniqueFilename.cpp
+@am__fastdepCXX_TRUE@  $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscioutput_stream_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT src/cpp/libscioutput_stream_algo_la-getUniqueFilename.lo -MD -MP -MF src/cpp/$(DEPDIR)/libscioutput_stream_algo_la-getUniqueFilename.Tpo -c -o src/cpp/libscioutput_stream_algo_la-getUniqueFilename.lo `test -f 'src/cpp/getUniqueFilename.cpp' || echo '$(srcdir)/'`src/cpp/getUniqueFilename.cpp
+@am__fastdepCXX_TRUE@  $(AM_V_at)$(am__mv) src/cpp/$(DEPDIR)/libscioutput_stream_algo_la-getUniqueFilename.Tpo src/cpp/$(DEPDIR)/libscioutput_stream_algo_la-getUniqueFilename.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     $(AM_V_CXX)source='src/cpp/getUniqueFilename.cpp' object='src/cpp/libscioutput_stream_algo_la-getUniqueFilename.lo' libtool=yes @AMDEPBACKSLASH@
 @AMDEP_TRUE@@am__fastdepCXX_FALSE@     DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscioutput_stream_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o src/cpp/libscioutput_stream_algo_la-getFullFilename.lo `test -f 'src/cpp/getFullFilename.cpp' || echo '$(srcdir)/'`src/cpp/getFullFilename.cpp
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscioutput_stream_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o src/cpp/libscioutput_stream_algo_la-getUniqueFilename.lo `test -f 'src/cpp/getUniqueFilename.cpp' || echo '$(srcdir)/'`src/cpp/getUniqueFilename.cpp
 
 src/cpp/libscioutput_stream_algo_la-scilab_sprintf.lo: src/cpp/scilab_sprintf.cpp
 @am__fastdepCXX_TRUE@  $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscioutput_stream_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT src/cpp/libscioutput_stream_algo_la-scilab_sprintf.lo -MD -MP -MF src/cpp/$(DEPDIR)/libscioutput_stream_algo_la-scilab_sprintf.Tpo -c -o src/cpp/libscioutput_stream_algo_la-scilab_sprintf.lo `test -f 'src/cpp/scilab_sprintf.cpp' || echo '$(srcdir)/'`src/cpp/scilab_sprintf.cpp
diff --git a/scilab/modules/output_stream/src/c/Fileio_Import.def b/scilab/modules/output_stream/src/c/Fileio_Import.def
new file mode 100644 (file)
index 0000000..b4420b3
--- /dev/null
@@ -0,0 +1,7 @@
+LIBRARY    fileio.dll
+
+
+EXPORTS
+FileExistW
+getFullFilenameW
+splitpathW
index 2fd408d..e4150cb 100644 (file)
@@ -80,7 +80,7 @@
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
     <ClCompile>
       <Optimization>Disabled</Optimization>
-      <AdditionalIncludeDirectories>.;../../includes;../jni;../cpp;../../../../libs/intl;$(SCILAB_JDK32)/include;$(SCILAB_JDK32)/include/win32;../../../core/includes;../../../dynamic_link/includes;../../../api_scilab/includes;../../../jvm/includes;../../../localization/includes;../../../string/includes;../../../windows_tools/includes;../../../console/includes;../../../console/src/c/windows;../../../threads/includes;../../../ast/includes/types;../../../ast/includes/ast;../../../ast/includes/analysis;../../../ast/includes/exps;../../../ast/includes/operations;../../../ast/includes/symbol;../../../ast/includes/system_env;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <AdditionalIncludeDirectories>.;../../includes;../cpp;../../../../libs/intl;../../../core/includes;../../../dynamic_link/includes;../../../api_scilab/includes;../../../jvm/includes;../../../localization/includes;../../../string/includes;../../../windows_tools/includes;../../../console/includes;../../../console/src/c/windows;../../../threads/includes;../../../ast/includes/types;../../../ast/includes/ast;../../../ast/includes/analysis;../../../ast/includes/exps;../../../ast/includes/operations;../../../ast/includes/symbol;../../../ast/includes/system_env;../../../fileio/includes;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
       <PreprocessorDefinitions>_CRT_SECURE_NO_DEPRECATE;FORDLL;_DEBUG;_WINDOWS;_USRDLL;OUTPUT_STREAM_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
       <WarningLevel>Level3</WarningLevel>
@@ -94,10 +94,11 @@ lib /DEF:"$(ProjectDir)Output_stream_f_Import.def" /SUBSYSTEM:WINDOWS /MACHINE:$
 lib /DEF:"$(ProjectDir)core_Import.def" /SUBSYSTEM:WINDOWS /MACHINE:$(PlatformShortName) /OUT:"$(ProjectDir)core.lib"  1&gt;NUL 2&gt;NUL
 lib /DEF:"$(ProjectDir)core_f_Import.def" /SUBSYSTEM:WINDOWS /MACHINE:$(PlatformShortName) /OUT:"$(ProjectDir)core_f.lib"  1&gt;NUL 2&gt;NUL
 lib /DEF:"$(ProjectDir)ast_Import.def" /SUBSYSTEM:WINDOWS /MACHINE:$(PlatformShortName) /OUT:"$(ProjectDir)ast.lib"  1&gt;NUL 2&gt;NUL
+lib /DEF:"$(ProjectDir)Fileio_Import.def" /SUBSYSTEM:WINDOWS /MACHINE:$(PlatformShortName) /OUT:"$(ProjectDir)fileio.lib"  1&gt;NUL 2&gt;NUL
 </Command>
     </PreLinkEvent>
     <Link>
-      <AdditionalDependencies>ast.lib;core.lib;sciconsole.lib;string.lib;output_stream_f.lib;core_f.lib;%(AdditionalDependencies)</AdditionalDependencies>
+      <AdditionalDependencies>ast.lib;core.lib;sciconsole.lib;string.lib;output_stream_f.lib;core_f.lib;fileio.lib;%(AdditionalDependencies)</AdditionalDependencies>
       <OutputFile>$(SolutionDir)bin\$(ProjectName).dll</OutputFile>
       <ModuleDefinitionFile>output_stream_export.def</ModuleDefinitionFile>
       <GenerateDebugInformation>true</GenerateDebugInformation>
@@ -116,7 +117,7 @@ lib /DEF:"$(ProjectDir)ast_Import.def" /SUBSYSTEM:WINDOWS /MACHINE:$(PlatformSho
     </Midl>
     <ClCompile>
       <Optimization>Disabled</Optimization>
-      <AdditionalIncludeDirectories>.;../../includes;../jni;../cpp;../../../../libs/intl;$(SCILAB_JDK64)/include;$(SCILAB_JDK64)/include/win32;../../../core/includes;../../../dynamic_link/includes;../../../api_scilab/includes;../../../jvm/includes;../../../localization/includes;../../../string/includes;../../../windows_tools/includes;../../../console/includes;../../../console/src/c/windows;../../../threads/includes;../../../ast/includes/types;../../../ast/includes/ast;../../../ast/includes/analysis;../../../ast/includes/exps;../../../ast/includes/operations;../../../ast/includes/symbol;../../../ast/includes/system_env;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <AdditionalIncludeDirectories>.;../../includes;../cpp;../../../../libs/intl;../../../core/includes;../../../dynamic_link/includes;../../../api_scilab/includes;../../../jvm/includes;../../../localization/includes;../../../string/includes;../../../windows_tools/includes;../../../console/includes;../../../console/src/c/windows;../../../threads/includes;../../../ast/includes/types;../../../ast/includes/ast;../../../ast/includes/analysis;../../../ast/includes/exps;../../../ast/includes/operations;../../../ast/includes/symbol;../../../ast/includes/system_env;../../../fileio/includes;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
       <PreprocessorDefinitions>_CRT_SECURE_NO_DEPRECATE;FORDLL;_DEBUG;_WINDOWS;_USRDLL;OUTPUT_STREAM_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
       <WarningLevel>Level3</WarningLevel>
@@ -130,10 +131,11 @@ lib /DEF:"$(ProjectDir)Output_stream_f_Import.def" /SUBSYSTEM:WINDOWS /MACHINE:$
 lib /DEF:"$(ProjectDir)core_Import.def" /SUBSYSTEM:WINDOWS /MACHINE:$(PlatformShortName) /OUT:"$(ProjectDir)core.lib"  1&gt;NUL 2&gt;NUL
 lib /DEF:"$(ProjectDir)core_f_Import.def" /SUBSYSTEM:WINDOWS /MACHINE:$(PlatformShortName) /OUT:"$(ProjectDir)core_f.lib"  1&gt;NUL 2&gt;NUL
 lib /DEF:"$(ProjectDir)ast_Import.def" /SUBSYSTEM:WINDOWS /MACHINE:$(PlatformShortName) /OUT:"$(ProjectDir)ast.lib"  1&gt;NUL 2&gt;NUL
+lib /DEF:"$(ProjectDir)Fileio_Import.def" /SUBSYSTEM:WINDOWS /MACHINE:$(PlatformShortName) /OUT:"$(ProjectDir)fileio.lib"  1&gt;NUL 2&gt;NUL
 </Command>
     </PreLinkEvent>
     <Link>
-      <AdditionalDependencies>ast.lib;core.lib;sciconsole.lib;string.lib;output_stream_f.lib;core_f.lib;%(AdditionalDependencies)</AdditionalDependencies>
+      <AdditionalDependencies>ast.lib;core.lib;sciconsole.lib;string.lib;output_stream_f.lib;core_f.lib;fileio.lib;%(AdditionalDependencies)</AdditionalDependencies>
       <OutputFile>$(SolutionDir)bin\$(ProjectName).dll</OutputFile>
       <ModuleDefinitionFile>output_stream_export.def</ModuleDefinitionFile>
       <GenerateDebugInformation>true</GenerateDebugInformation>
@@ -150,7 +152,7 @@ lib /DEF:"$(ProjectDir)ast_Import.def" /SUBSYSTEM:WINDOWS /MACHINE:$(PlatformSho
     <ClCompile>
       <FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
       <WholeProgramOptimization>false</WholeProgramOptimization>
-      <AdditionalIncludeDirectories>.;../../includes;../jni;../cpp;../../../../libs/intl;$(SCILAB_JDK32)/include;$(SCILAB_JDK32)/include/win32;../../../core/includes;../../../dynamic_link/includes;../../../api_scilab/includes;../../../jvm/includes;../../../localization/includes;../../../string/includes;../../../windows_tools/includes;../../../console/includes;../../../console/src/c/windows;../../../threads/includes;../../../ast/includes/types;../../../ast/includes/ast;../../../ast/includes/analysis;../../../ast/includes/exps;../../../ast/includes/operations;../../../ast/includes/symbol;../../../ast/includes/system_env;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <AdditionalIncludeDirectories>.;../../includes;../cpp;../../../../libs/intl;../../../core/includes;../../../dynamic_link/includes;../../../api_scilab/includes;../../../jvm/includes;../../../localization/includes;../../../string/includes;../../../windows_tools/includes;../../../console/includes;../../../console/src/c/windows;../../../threads/includes;../../../ast/includes/types;../../../ast/includes/ast;../../../ast/includes/analysis;../../../ast/includes/exps;../../../ast/includes/operations;../../../ast/includes/symbol;../../../ast/includes/system_env;../../../fileio/includes;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
       <PreprocessorDefinitions>_CRT_SECURE_NO_DEPRECATE;FORDLL;NDEBUG;_WINDOWS;_USRDLL;OUTPUT_STREAM_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <StringPooling>true</StringPooling>
       <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
@@ -166,10 +168,11 @@ lib /DEF:"$(ProjectDir)Output_stream_f_Import.def" /SUBSYSTEM:WINDOWS /MACHINE:$
 lib /DEF:"$(ProjectDir)core_Import.def" /SUBSYSTEM:WINDOWS /MACHINE:$(PlatformShortName) /OUT:"$(ProjectDir)core.lib"  1&gt;NUL 2&gt;NUL
 lib /DEF:"$(ProjectDir)core_f_Import.def" /SUBSYSTEM:WINDOWS /MACHINE:$(PlatformShortName) /OUT:"$(ProjectDir)core_f.lib"  1&gt;NUL 2&gt;NUL
 lib /DEF:"$(ProjectDir)ast_Import.def" /SUBSYSTEM:WINDOWS /MACHINE:$(PlatformShortName) /OUT:"$(ProjectDir)ast.lib"  1&gt;NUL 2&gt;NUL
+lib /DEF:"$(ProjectDir)Fileio_Import.def" /SUBSYSTEM:WINDOWS /MACHINE:$(PlatformShortName) /OUT:"$(ProjectDir)fileio.lib"  1&gt;NUL 2&gt;NUL
 </Command>
     </PreLinkEvent>
     <Link>
-      <AdditionalDependencies>ast.lib;core.lib;sciconsole.lib;string.lib;output_stream_f.lib;core_f.lib;%(AdditionalDependencies)</AdditionalDependencies>
+      <AdditionalDependencies>ast.lib;core.lib;sciconsole.lib;string.lib;output_stream_f.lib;core_f.lib;fileio.lib;%(AdditionalDependencies)</AdditionalDependencies>
       <OutputFile>$(SolutionDir)bin\$(ProjectName).dll</OutputFile>
       <ModuleDefinitionFile>output_stream_export.def</ModuleDefinitionFile>
       <GenerateDebugInformation>false</GenerateDebugInformation>
@@ -191,7 +194,7 @@ lib /DEF:"$(ProjectDir)ast_Import.def" /SUBSYSTEM:WINDOWS /MACHINE:$(PlatformSho
     <ClCompile>
       <FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
       <WholeProgramOptimization>false</WholeProgramOptimization>
-      <AdditionalIncludeDirectories>.;../../includes;../jni;../cpp;../../../../libs/intl;$(SCILAB_JDK64)/include;$(SCILAB_JDK64)/include/win32;../../../core/includes;../../../dynamic_link/includes;../../../api_scilab/includes;../../../jvm/includes;../../../localization/includes;../../../string/includes;../../../windows_tools/includes;../../../console/includes;../../../console/src/c/windows;../../../threads/includes;../../../ast/includes/types;../../../ast/includes/ast;../../../ast/includes/analysis;../../../ast/includes/exps;../../../ast/includes/operations;../../../ast/includes/symbol;../../../ast/includes/system_env;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <AdditionalIncludeDirectories>.;../../includes;../cpp;../../../../libs/intl;../../../core/includes;../../../dynamic_link/includes;../../../api_scilab/includes;../../../jvm/includes;../../../localization/includes;../../../string/includes;../../../windows_tools/includes;../../../console/includes;../../../console/src/c/windows;../../../threads/includes;../../../ast/includes/types;../../../ast/includes/ast;../../../ast/includes/analysis;../../../ast/includes/exps;../../../ast/includes/operations;../../../ast/includes/symbol;../../../ast/includes/system_env;../../../fileio/includes;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
       <PreprocessorDefinitions>_CRT_SECURE_NO_DEPRECATE;FORDLL;NDEBUG;_WINDOWS;_USRDLL;OUTPUT_STREAM_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <StringPooling>true</StringPooling>
       <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
@@ -207,10 +210,11 @@ lib /DEF:"$(ProjectDir)Output_stream_f_Import.def" /SUBSYSTEM:WINDOWS /MACHINE:$
 lib /DEF:"$(ProjectDir)core_Import.def" /SUBSYSTEM:WINDOWS /MACHINE:$(PlatformShortName) /OUT:"$(ProjectDir)core.lib"  1&gt;NUL 2&gt;NUL
 lib /DEF:"$(ProjectDir)core_f_Import.def" /SUBSYSTEM:WINDOWS /MACHINE:$(PlatformShortName) /OUT:"$(ProjectDir)core_f.lib"  1&gt;NUL 2&gt;NUL
 lib /DEF:"$(ProjectDir)ast_Import.def" /SUBSYSTEM:WINDOWS /MACHINE:$(PlatformShortName) /OUT:"$(ProjectDir)ast.lib"  1&gt;NUL 2&gt;NUL
+lib /DEF:"$(ProjectDir)Fileio_Import.def" /SUBSYSTEM:WINDOWS /MACHINE:$(PlatformShortName) /OUT:"$(ProjectDir)fileio.lib"  1&gt;NUL 2&gt;NUL
 </Command>
     </PreLinkEvent>
     <Link>
-      <AdditionalDependencies>ast.lib;core.lib;sciconsole.lib;string.lib;output_stream_f.lib;core_f.lib;%(AdditionalDependencies)</AdditionalDependencies>
+      <AdditionalDependencies>ast.lib;core.lib;sciconsole.lib;string.lib;output_stream_f.lib;core_f.lib;fileio.lib;%(AdditionalDependencies)</AdditionalDependencies>
       <OutputFile>$(SolutionDir)bin\$(ProjectName).dll</OutputFile>
       <ModuleDefinitionFile>output_stream_export.def</ModuleDefinitionFile>
       <GenerateDebugInformation>false</GenerateDebugInformation>
@@ -227,6 +231,7 @@ lib /DEF:"$(ProjectDir)ast_Import.def" /SUBSYSTEM:WINDOWS /MACHINE:$(PlatformSho
   </ItemDefinitionGroup>
   <ItemGroup>
     <ClCompile Include="..\cpp\basout.cpp" />
+    <ClCompile Include="..\cpp\getUniqueFilename.cpp" />
     <ClCompile Include="cerro.c" />
     <ClCompile Include="..\cpp\Diary.cpp" />
     <ClCompile Include="..\cpp\diary_manager.cpp" />
@@ -235,7 +240,6 @@ lib /DEF:"$(ProjectDir)ast_Import.def" /SUBSYSTEM:WINDOWS /MACHINE:$(PlatformSho
     <ClCompile Include="erro.c" />
     <ClCompile Include="error.c" />
     <ClCompile Include="..\cpp\getDiaryDate.cpp" />
-    <ClCompile Include="..\cpp\getFullFilename.cpp" />
     <ClCompile Include="msgout.c" />
     <ClCompile Include="msgs.c" />
     <ClCompile Include="msgstore.c" />
@@ -250,6 +254,7 @@ lib /DEF:"$(ProjectDir)ast_Import.def" /SUBSYSTEM:WINDOWS /MACHINE:$(PlatformSho
     <None Include="Console_Import.def" />
     <None Include="Core_f_Import.def" />
     <None Include="core_import.def" />
+    <None Include="Fileio_Import.def" />
     <None Include="Localization_Import.def" />
     <None Include="output_stream_f_Import.def" />
     <None Include="String_Import.def" />
@@ -289,7 +294,7 @@ lib /DEF:"$(ProjectDir)ast_Import.def" /SUBSYSTEM:WINDOWS /MACHINE:$(PlatformSho
     <ClInclude Include="..\cpp\DiaryModesEnum.hxx" />
     <ClInclude Include="..\cpp\diary_manager.hxx" />
     <ClInclude Include="..\cpp\getDiaryDate.hxx" />
-    <ClInclude Include="..\cpp\getFullFilename.hxx" />
+    <ClInclude Include="..\cpp\getUniqueFilename.hxx" />
     <ClInclude Include="errorTable.h" />
     <ClInclude Include="error_internal.h" />
     <ClInclude Include="msgout.h" />
index 4d0fcff..ee791e9 100644 (file)
@@ -50,9 +50,6 @@
     <ClCompile Include="..\cpp\getDiaryDate.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
-    <ClCompile Include="..\cpp\getFullFilename.cpp">
-      <Filter>Source Files</Filter>
-    </ClCompile>
     <ClCompile Include="msgout.c">
       <Filter>Source Files</Filter>
     </ClCompile>
@@ -80,6 +77,9 @@
     <ClCompile Include="..\cpp\basout.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
+    <ClCompile Include="..\cpp\getUniqueFilename.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <None Include="Console_Import.def">
     <None Include="..\..\locales\output_stream.pot">
       <Filter>localization</Filter>
     </None>
+    <None Include="Fileio_Import.def">
+      <Filter>Libraries Dependencies\Imports</Filter>
+    </None>
   </ItemGroup>
   <ItemGroup>
     <ResourceCompile Include="output_stream.rc">
     <ClInclude Include="..\cpp\getDiaryDate.hxx">
       <Filter>Header Files</Filter>
     </ClInclude>
-    <ClInclude Include="..\cpp\getFullFilename.hxx">
+    <ClInclude Include="..\..\includes\msgs.h">
       <Filter>Header Files</Filter>
     </ClInclude>
-    <ClInclude Include="..\..\includes\msgs.h">
+    <ClInclude Include="..\cpp\getUniqueFilename.hxx">
       <Filter>Header Files</Filter>
     </ClInclude>
   </ItemGroup>
index 3f8e34d..6d0ca85 100644 (file)
 #include <fstream>
 #include <iostream>
 #include "Diary.hxx"
-#include "getFullFilename.hxx"
 #include "getDiaryDate.hxx"
+#include "getUniqueFilename.hxx"
+
 extern "C"
 {
+#include "getFullFilename.h"
 #include "charEncoding.h"
 #include "sci_malloc.h"
 }
 /*--------------------------------------------------------------------------*/
-Diary::Diary(std::wstring _wfilename, int _mode, int ID, bool autorename)
+Diary::Diary(const std::wstring& _wfilename, int _mode, int ID, bool autorename)
 {
     std::ios::openmode wofstream_mode;
 
@@ -30,11 +32,16 @@ Diary::Diary(std::wstring _wfilename, int _mode, int ID, bool autorename)
     if (autorename)
     {
         fullfilename = getUniqueFilename(_wfilename);
-        fullfilename = getFullFilename(fullfilename);
+
+        wchar_t* ws = getFullFilenameW(fullfilename.data());
+        fullfilename = ws;
+        FREE(ws);
     }
     else
     {
-        fullfilename = getFullFilename(_wfilename);
+        wchar_t* ws = getFullFilenameW(_wfilename.data());
+        fullfilename = ws;
+        FREE(ws);
     }
 
     suspendwrite = false;
@@ -53,7 +60,7 @@ Diary::Diary(std::wstring _wfilename, int _mode, int ID, bool autorename)
     }
 
 #ifdef _MSC_VER
-    std::wofstream fileDiary(fullfilename.c_str(), wofstream_mode);
+    std::wofstream fileDiary(fullfilename, wofstream_mode);
 #else
     wchar_t *wcfile = (wchar_t *) fullfilename.c_str();
     char *filename = wide_string_to_UTF8(wcfile);
@@ -85,7 +92,7 @@ Diary::Diary(std::wstring _wfilename, int _mode, int ID, bool autorename)
 /*--------------------------------------------------------------------------*/
 Diary::~Diary()
 {
-    wfilename = std::wstring(L"");
+    wfilename = L"";
     fileAttribMode = -1;
     setID(-1);
 }
@@ -97,7 +104,7 @@ std::wstring Diary::getFilename(void)
 }
 
 /*--------------------------------------------------------------------------*/
-void Diary::write(std::wstring _wstr, bool bInput)
+void Diary::write(const std::wstring& _wstr, bool bInput)
 {
     if (!suspendwrite)
     {
@@ -120,13 +127,13 @@ void Diary::write(std::wstring _wstr, bool bInput)
         if (fileDiary.good())
         {
             char *line = NULL;
-
+            std::wstring wst = _wstr;
 #ifdef _MSC_VER
             /* carriage return for Windows */
-            _wstr = replace(_wstr, std::wstring(L"\n"), std::wstring(L"\r\n"));
-            _wstr = replace(_wstr, std::wstring(L"\r\r"), std::wstring(L"\r"));
+            wst = replace(wst, std::wstring(L"\n"), std::wstring(L"\r\n"));
+            wst = replace(wst, std::wstring(L"\r\r"), std::wstring(L"\r"));
 #endif
-            line = wide_string_to_UTF8((wchar_t *) _wstr.c_str());
+            line = wide_string_to_UTF8(wst.data());
 
             if (bInput)         // input
             {
@@ -182,14 +189,14 @@ void Diary::write(std::wstring _wstr, bool bInput)
 }
 
 /*--------------------------------------------------------------------------*/
-void Diary::writeln(std::wstring _wstr, bool bInput)
+void Diary::writeln(const std::wstring& _wstr, bool bInput)
 {
 #define ENDLINE L"\n"
-    write(_wstr.append(ENDLINE), bInput);
+    write(_wstr + ENDLINE, bInput);
 }
 
 /*--------------------------------------------------------------------------*/
-int Diary::getID(void)
+int Diary::getID(void) const 
 {
     return ID_foutstream;
 }
@@ -216,23 +223,23 @@ bool Diary::getSuspendWrite(void)
 }
 
 /*--------------------------------------------------------------------------*/
-std::wstring Diary::replace(std::wstring text, std::wstring s, std::wstring replacement)
+std::wstring Diary::replace(const std::wstring& text, const std::wstring& s, const std::wstring& replacement)
 {
     std::wstring::size_type pos = 0;
-
+    std::wstring ret = text;
     while (pos != std::wstring::npos)
     {
-        pos = text.find(s, pos);
+        pos = ret.find(s, pos);
         if (pos == std::wstring::npos)
             // no more 's' in '*this'
         {
             break;
         }
 
-        text.replace(pos, s.length(), replacement);
+        ret.replace(pos, s.length(), replacement);
         pos += replacement.length();
     }
-    return text;
+    return ret;
 }
 
 /*--------------------------------------------------------------------------*/
@@ -272,7 +279,7 @@ diary_prefix_time_filter Diary::getPrefixIoModeFilter(void)
 }
 
 /*--------------------------------------------------------------------------*/
-bool compareDiary(Diary first, Diary second)
+bool compareDiary(const Diary& first, const Diary& second)
 {
     if (first.getID() < second.getID())
     {
index 03f3788..aedf0af 100644 (file)
@@ -43,13 +43,13 @@ private:
     /*
     * used on Windows to replace carriage return
     */
-    std::wstring replace(std::wstring text, std::wstring s, std::wstring replacement);
+    std::wstring replace(const std::wstring& text, const std::wstring& s, const std::wstring& replacement);
 
 public:
     /*
     * constructor
     */
-    Diary(std::wstring _wfilename, int _mode, int ID, bool autorename);
+    Diary(const std::wstring& _wfilename, int _mode, int ID, bool autorename);
 
     /*
     * destructor
@@ -70,17 +70,17 @@ public:
     /*
     * get ID of this diary
     */
-    int getID(void);
+    int getID(void) const;
 
     /*
     * write a string in this diary
     */
-    void write(std::wstring _wstr, bool bInput);
+    void write(const std::wstring& _wstr, bool bInput);
 
     /*
     * write a line in this diary
     */
-    void writeln(std::wstring _wstr, bool bInput);
+    void writeln(const std::wstring& _wstr, bool bInput);
 
     /*
     * get & set Resume mode
@@ -103,5 +103,5 @@ public:
 
 #endif /* __DIARY_HXX__ */
 /*--------------------------------------------------------------------------*/
-bool compareDiary(Diary first, Diary second);
+bool compareDiary(const Diary& first, const Diary& second);
 /*--------------------------------------------------------------------------*/
index e80da76..ebc78fa 100644 (file)
 */
 /*--------------------------------------------------------------------------*/
 #include "DiaryList.hxx"
-#include "getFullFilename.hxx"
+
+extern "C"
+{
+#include "getFullFilename.h"
+#include "sci_malloc.h"
+}
 /*--------------------------------------------------------------------------*/
 DiaryList::DiaryList()
 {
@@ -151,7 +156,10 @@ bool DiaryList::exists(std::wstring _wfilename)
     std::list<Diary>::iterator i;
     for ( i = LSTDIARY.begin(); i != LSTDIARY.end(); i++)
     {
-        if ( i->getFilename().compare(getFullFilename(_wfilename)) == 0 )
+        wchar_t* wc = getFullFilenameW(_wfilename.data());
+        int comp = i->getFilename().compare(wc);
+        FREE(wc);
+        if (comp == 0)
         {
             return true;
         }
@@ -239,7 +247,10 @@ int DiaryList::getID(std::wstring _wfilename)
     std::list<Diary>::iterator i;
     for ( i = LSTDIARY.begin(); i != LSTDIARY.end(); i++)
     {
-        if ( i->getFilename().compare(getFullFilename(_wfilename)) == 0 )
+        wchar_t* ws = getFullFilenameW(_wfilename.data());
+        int comp = i->getFilename().compare(ws);
+        FREE(ws);
+        if (comp == 0)
         {
             return i->getID();
         }
diff --git a/scilab/modules/output_stream/src/cpp/getFullFilename.cpp b/scilab/modules/output_stream/src/cpp/getFullFilename.cpp
deleted file mode 100644 (file)
index 4c23289..0000000
+++ /dev/null
@@ -1,240 +0,0 @@
-/*--------------------------------------------------------------------------*/
-/*
-* ( http://www.scilab.org/ ) - This file is part of Scilab
-* Copyright (C) DIGITEO - 2009 - Allan CORNET
-*
-* This file must be used under the terms of the CeCILL.
-* This source file is licensed as described in the file COPYING, which
-* you should have received as part of this distribution.  The terms
-* are also available at
-* http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
-*
-*/
-/*--------------------------------------------------------------------------*/
-#include <fstream>
-#include <iostream>
-#include <sstream>
-#include "getFullFilename.hxx"
-/*--------------------------------------------------------------------------*/
-#ifndef _MSC_VER
-#include <unistd.h>
-#endif
-extern "C"
-{
-#include "machine.h"
-#include "PATH_MAX.h"
-#include "sci_malloc.h"
-#include "charEncoding.h"
-}
-/*--------------------------------------------------------------------------*/
-static void wcsplitpath(const wchar_t* path, wchar_t* drv, wchar_t* dir, wchar_t* name, wchar_t* ext);
-static bool fileExists(std::wstring _wfilename);
-static int GetFileSize(std::wstring _wfilename);
-/*--------------------------------------------------------------------------*/
-std::wstring getFullFilename(std::wstring _wfilename)
-{
-    wchar_t wcdrive[PATH_MAX];
-    wchar_t wcdirectory[PATH_MAX];
-    wchar_t wcname[PATH_MAX];
-    wchar_t wcext [PATH_MAX];
-
-    std::wstring wfullfilename(L"");
-    std::wstring tmpWstr;
-
-    size_t found = _wfilename.rfind(L"\\");
-
-    while (found != std::wstring::npos)
-    {
-        _wfilename.replace (found, 1, L"/");
-        found = _wfilename.rfind(L"\\");
-    }
-    wcsplitpath(_wfilename.c_str(), wcdrive, wcdirectory, wcname, wcext);
-    wfullfilename.append(tmpWstr.assign(wcdrive));
-    wfullfilename.append(tmpWstr.assign(wcdirectory));
-    if (wfullfilename.compare(L"") == 0)
-    {
-        /* to get current directory as wide characters */
-#if _MSC_VER
-        wchar_t wcCurrentDir[PATH_MAX];
-        if ( _wgetcwd(wcCurrentDir, PATH_MAX) != NULL)
-        {
-            wfullfilename = tmpWstr.assign(wcCurrentDir);
-#else
-        char CurrentDir[PATH_MAX];
-        if (getcwd(CurrentDir, PATH_MAX) != NULL)
-        {
-            wchar_t *wcCurrentDir = to_wide_string(CurrentDir);
-            wfullfilename = tmpWstr.assign(wcCurrentDir);
-            FREE(wcCurrentDir);
-#endif
-            /* replaces separator */
-            size_t found = wfullfilename.rfind(L"\\");
-            while (found != std::wstring::npos)
-            {
-                wfullfilename.replace (found, 1, L"/");
-                found = wfullfilename.rfind(L"\\");
-            }
-            wfullfilename.append(L"/");
-
-        }
-        else
-        {
-            wfullfilename.assign(L"");
-        }
-    }
-    wfullfilename.append(tmpWstr.assign(wcname));
-    wfullfilename.append(tmpWstr.assign(wcext));
-
-    return wfullfilename;
-}
-/*--------------------------------------------------------------------------*/
-static void wcsplitpath(const wchar_t* path, wchar_t* drv, wchar_t* dir, wchar_t* name, wchar_t* ext)
-{
-    const wchar_t* end; /* end of processed string */
-    const wchar_t* p;   /* search pointer */
-    const wchar_t* s;   /* copy pointer */
-
-    /* extract drive name */
-    if (path[0] && path[1] == ':')
-    {
-        if (drv)
-        {
-            *drv++ = *path++;
-            *drv++ = *path++;
-            *drv = L'\0';
-        }
-    }
-    else if (drv)
-    {
-        *drv = L'\0';
-    }
-
-    /* search for end of string or stream separator */
-    for (end = path; *end && *end != L':'; )
-    {
-        end++;
-    }
-
-    /* search for begin of file extension */
-    for (p = end; p > path && *--p != L'\\' && *p != L'/'; )
-    {
-        if (*p == L'.')
-        {
-            end = p;
-            break;
-        }
-    }
-
-    if (ext) for (s = end; (*ext = *s++); )
-        {
-            ext++;
-        }
-
-    /* search for end of directory name */
-    for (p = end; p > path; )
-    {
-        if (*--p == '\\' || *p == '/')
-        {
-            p++;
-            break;
-        }
-    }
-    if (name)
-    {
-        for (s = p; s < end; )
-        {
-            *name++ = *s++;
-        }
-        *name = L'\0';
-    }
-
-    if (dir)
-    {
-        for (s = path; s < p; )
-        {
-            *dir++ = *s++;
-        }
-        *dir = L'\0';
-    }
-}
-/*--------------------------------------------------------------------------*/
-std::wstring getUniqueFilename(std::wstring _wfilename)
-{
-    std::wstring wfullfilename = getFullFilename(_wfilename);
-    std::wstring newfilename;
-
-    if (fileExists(wfullfilename) == true)
-    {
-        wchar_t wcdrive[PATH_MAX];
-        wchar_t wcdirectory[PATH_MAX];
-        wchar_t wcname[PATH_MAX];
-        wchar_t wcext [PATH_MAX];
-        unsigned int id = (unsigned int)(-1);
-
-        std::wstring prefixFilename;
-
-        wcsplitpath(_wfilename.c_str(), wcdrive, wcdirectory, wcname, wcext);
-        prefixFilename.assign(L"");
-        prefixFilename.append(wcdrive);
-        prefixFilename.append(wcdirectory);
-        prefixFilename.append(wcname);
-
-        do
-        {
-            std::wstringstream StrStream;
-            id++;
-            StrStream << (unsigned int)id;
-            newfilename = prefixFilename + L"_" + StrStream.str() + wcext;
-        }
-        while ( (fileExists(newfilename) == true) && (GetFileSize(newfilename) != 0) );
-    }
-    else
-    {
-        newfilename = wfullfilename;
-    }
-    return newfilename;
-}
-/*--------------------------------------------------------------------------*/
-static bool fileExists(std::wstring _wfilename)
-{
-    bool returnVal = false;
-#if _MSC_VER
-    std::wifstream f(_wfilename.c_str());
-#else
-    char *_filename = wide_string_to_UTF8((wchar_t*)_wfilename.c_str());
-    if (_filename == NULL)
-    {
-        return false;
-    }
-    std::ifstream f(_filename);
-    FREE(_filename);
-    _filename = NULL;
-#endif
-    if (f.is_open())
-    {
-        f.close();
-        returnVal = true;
-    }
-    else
-    {
-        returnVal = false;
-    }
-    return returnVal;
-}
-/*--------------------------------------------------------------------------*/
-static int GetFileSize(std::wstring _wfilename)
-{
-#ifdef _MSC_VER
-    std::wifstream file(_wfilename.c_str());
-#else
-    char *_filename = wide_string_to_UTF8((wchar_t*)_wfilename.c_str());
-    if (_filename == NULL)
-    {
-        return false;
-    }
-    std::ifstream file(_filename);
-#endif
-    file.seekg(std::ios::end);
-    return (int)file.tellg();
-}
-/*--------------------------------------------------------------------------*/
diff --git a/scilab/modules/output_stream/src/cpp/getUniqueFilename.cpp b/scilab/modules/output_stream/src/cpp/getUniqueFilename.cpp
new file mode 100644 (file)
index 0000000..8fb6067
--- /dev/null
@@ -0,0 +1,90 @@
+/*--------------------------------------------------------------------------*/
+/*
+* ( http://www.scilab.org/ ) - This file is part of Scilab
+* Copyright (C) DIGITEO - 2009 - Allan CORNET
+*
+* This file must be used under the terms of the CeCILL.
+* This source file is licensed as described in the file COPYING, which
+* you should have received as part of this distribution.  The terms
+* are also available at
+* http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+*
+*/
+/*--------------------------------------------------------------------------*/
+#include <fstream>
+#include <iostream>
+#include <sstream>
+/*--------------------------------------------------------------------------*/
+#ifndef _MSC_VER
+#include <unistd.h>
+#endif
+extern "C"
+{
+#include "machine.h"
+#include "PATH_MAX.h"
+#include "sci_malloc.h"
+#include "getFullFilename.h"
+#include "splitpath.h"
+#include "FileExist.h"
+#include "charEncoding.h"
+}
+/*--------------------------------------------------------------------------*/
+static void wcsplitpath(const wchar_t* path, wchar_t* drv, wchar_t* dir, wchar_t* name, wchar_t* ext);
+static int getFileSize(const std::wstring& _wfilename);
+/*--------------------------------------------------------------------------*/
+std::wstring getUniqueFilename(const std::wstring& _wfilename)
+{
+    wchar_t* ws = getFullFilenameW(_wfilename.data());
+    std::wstring wfullfilename(ws);
+    FREE(ws);
+    std::wstring newfilename;
+
+    if (FileExistW(wfullfilename.data()))
+    {
+        wchar_t wcdrive[PATH_MAX];
+        wchar_t wcdirectory[PATH_MAX];
+        wchar_t wcname[PATH_MAX];
+        wchar_t wcext[PATH_MAX];
+        unsigned int id = (unsigned int)(-1);
+
+        splitpathW(wfullfilename.data(), FALSE, wcdrive, wcdirectory, wcname, wcext);
+        std::wstring prefixFilename(wcdrive);
+        prefixFilename += wcdirectory;
+        prefixFilename += wcname;
+
+        do
+        {
+            id++;
+            newfilename = prefixFilename + L"_" + std::to_wstring(id) + wcext;
+        } while (FileExistW(newfilename.data()) && getFileSize(newfilename) != 0);
+    }
+    else
+    {
+        newfilename = wfullfilename;
+    }
+    return newfilename;
+}
+/*--------------------------------------------------------------------------*/
+static int getFileSize(const std::wstring& _wfilename)
+{
+#ifdef _MSC_VER
+    std::wifstream file(_wfilename.c_str());
+#else
+    char *_filename = wide_string_to_UTF8((wchar_t*)_wfilename.c_str());
+    if (_filename == NULL)
+    {
+        return false;
+    }
+    std::ifstream file(_filename);
+#endif
+    file.seekg(std::ios::end);
+    if(file.is_open())
+    {
+        int size = (int)file.tellg();
+        file.close();
+        return size;
+    }
+
+    return 0;
+}
+/*--------------------------------------------------------------------------*/
 
 #include <string>
 
-/**
-* get full filename with path of a file
-* @param[in] std::wstring input filename
-* @return std::wstring full filename
-*/
-std::wstring getFullFilename(std::wstring _wfilename);
-
-
-std::wstring getUniqueFilename(std::wstring _wfilename);
+std::wstring getUniqueFilename(const std::wstring& _wfilename);
 
 #endif /* __GETFULLFILENAME_HXX__ */
 /*--------------------------------------------------------------------------*/
index 28f8aac..9637dd5 100644 (file)
 //    mprintf and diary don't work together
 //    after each character of the string generated by
 //    mprintf a newline character is inserted
-// Génération du fichier de référence
-prompt_str = "-" +"-"+ ">"; // tips since prompt is replaced by test_run
-l = [prompt_str + "mprintf(''hello world\n'')";"hello world";prompt_str + "diary(TMPDIR+''/bug557.dia'');"];
-l2 = ["hello world";" "];
+// Create a ref file
+prompt_str = prompt();
+l = ["";prompt_str + "mprintf(""hello world\n"")";"hello world";"";prompt_str + "diary(TMPDIR+""/bug557.dia"", ""close"");"];
 mputl(l, TMPDIR+'/bug557.ref');
-// Génération du fichier rapport
-diary(TMPDIR+'/bug557.dia');
-mprintf('hello world\n')
+//create a diary file
+diary(TMPDIR+"/bug557.dia");
+mprintf("hello world\n")
 hello world
-diary(TMPDIR+'/bug557.dia');
-// Comparaison
-ref = mgetl(TMPDIR+'/bug557.ref');
-dia = mgetl(TMPDIR+'/bug557.dia');
-// Affichage du résultat
-ref
- ref  =
-!mprintf('hello world\n')      !
-!                                 !
-!hello world                      !
-!                                 !
-!diary(TMPDIR+'/bug557.dia');  !
-dia
- dia  =
-!mprintf('hello world\n')      !
-!                                 !
-!hello world                      !
-!                                 !
-!diary(TMPDIR+'/bug557.dia');  !
+diary(TMPDIR+"/bug557.dia", "close");
+//compare two files
+ref = mgetl(TMPDIR+"/bug557.ref");
+dia = mgetl(TMPDIR+"/bug557.dia");
 assert_checkequal(ref, dia);
index f0b9b7a..6c46d49 100644 (file)
 //    after each character of the string generated by
 //    mprintf a newline character is inserted
 
-// Génération du fichier de référence
-prompt_str = "-" +"-"+ ">"; // tips since prompt is replaced by test_run
-l = [prompt_str + "mprintf(''hello world\n'')";"hello world";prompt_str + "diary(TMPDIR+''/bug557.dia'');"];
-l2 = ["hello world";" "];
+// Create a ref file
+prompt_str = prompt();
+l = ["";prompt_str + "mprintf(""hello world\n"")";"hello world";"";prompt_str + "diary(TMPDIR+""/bug557.dia"", ""close"");"];
 mputl(l, TMPDIR+'/bug557.ref');
 
-// Génération du fichier rapport
+//create a diary file
+diary(TMPDIR+"/bug557.dia");
+mprintf("hello world\n")
+diary(TMPDIR+"/bug557.dia", "close");
 
-diary(TMPDIR+'/bug557.dia');
-mprintf('hello world\n')
-diary(TMPDIR+'/bug557.dia');
+//compare two files
+ref = mgetl(TMPDIR+"/bug557.ref");
+dia = mgetl(TMPDIR+"/bug557.dia");
 
-// Comparaison
-ref = mgetl(TMPDIR+'/bug557.ref');
-dia = mgetl(TMPDIR+'/bug557.dia');
-
-// Affichage du résultat
-ref
-dia
 assert_checkequal(ref, dia);
index 8385dfc..16390cf 100644 (file)
@@ -24,5 +24,5 @@ warning("i like pizza very much")
 WARNING: i like pizza very much
 diary(fd, 'close');
 txt = mgetl(FILENAME_DIARY);
-s = strsplit(txt(2),' ');
+s = strsplit(txt(3),' ');
 assert_checkequal(s($), 'much');
index 2c89ee8..f35603f 100644 (file)
@@ -24,5 +24,5 @@ fd = diary(FILENAME_DIARY, 'new','prefix=YYYY-MM-DD hh:mm:ss');
 warning("i like pizza very much")
 diary(fd, 'close');
 txt = mgetl(FILENAME_DIARY);
-s = strsplit(txt(2),' ');
+s = strsplit(txt(3),' ');
 assert_checkequal(s($), 'much');