54 #include <wx/filename.h>
56 #include <wx/wxcrtvararg.h>
57 #include <wx/wfstream.h>
58 #include <wx/zipstrm.h>
59 #include <wx/tarstrm.h>
60 #include <wx/txtstrm.h>
62 #include <wx/version.h>
74 #define m_pStream_Base ((wxStreamBase *)m_pStream)
75 #define m_pStream_I ((wxFFileInputStream *)m_pStream)
76 #define m_pStream_O ((wxFFileOutputStream *)m_pStream)
77 #define m_pStream_IO ((wxFFileStream *)m_pStream)
97 Open(FileName, Mode, bBinary, Encoding);
116 if( !_FileName ) {
return(
false ); }
CSG_String FileName(_FileName);
137 m_pStream =
new wxFFileOutputStream(FileName.
c_str(), bBinary ?
"wb" :
"w");
141 m_pStream =
new wxFFileInputStream (FileName.
c_str(), bBinary ?
"rb" :
"r");
146 ? (bBinary ?
"r+b" :
"r+")
147 : (bBinary ?
"w+b" :
"w+")
296 wxString _Format(Format); _Format.Replace(
"%s",
"%ls");
297 va_list argptr; va_start(argptr, _Format);
298 int Result = String.PrintfV(_Format, argptr);
300 va_list argptr; va_start(argptr, Format);
301 int Result = String.PrintfV(Format, argptr);
321 wxString _Format(Format); _Format.Replace(
"%s",
"%ls");
322 va_list argptr; va_start(argptr, _Format);
323 int Result = String.PrintfV(_Format, argptr);
325 va_list argptr; va_start(argptr, Format);
326 int Result = String.PrintfV(Format, argptr);
341 :
m_pStream_IO->Read(Buffer, Size * Count).LastRead() / Size
381 wxString _Buffer(Buffer.
w_str());
383 const wxScopedCharBuffer s(_Buffer.mb_str(*((wxMBConv *)
m_pConvert)));
385 return(
Write((
void *)s.data(),
sizeof(
char), s.length()) );
418 wxTextInputStream Stream(*
m_pStream_I ,
" \t" ); s = Stream.ReadLine();
422 wxTextInputStream Stream(*
m_pStream_IO,
" \t" ); s = Stream.ReadLine();
442 if(
Read(&Value,
sizeof(Value)) == 1 )
460 return(
Write(&Value,
sizeof(Value)) ==
sizeof(Value) );
468 if(
Read(&Value,
sizeof(Value)) == 1 )
486 return(
Write(&Value,
sizeof(Value)) ==
sizeof(Value) );
496 if( isdigit(c) || strchr(
"-+", c) )
505 return( s.
asInt(Value) );
518 if( isdigit(c) || strchr(
"-+.,eE", c) )
522 while( !
is_EOF() && (isdigit(c =
Read_Char()) || strchr(
".,eE", c) || strchr(
"", c)) )
540 int c;
while( !
is_EOF() && (c =
Read_Char()) != Separator && c != EOF )
554 int Value;
return(
Scan(Value) ? Value : 0 );
559 double Value;
return(
Scan(Value) ? Value : 0.0 );
585 Open(FileName, Mode, Encoding);
599 if( !_FileName ) {
return(
false ); }
CSG_String FileName(_FileName);
660 wxArchiveEntry *pEntry;
662 while( (pEntry = ((wxArchiveInputStream *)
m_pStream)->GetNextEntry()) != NULL )
678 delete((wxZipEntry *)
m_Files[i]);
682 delete((wxTarEntry *)
m_Files[i]);
696 return(
is_Writing() && Name && ((wxArchiveOutputStream *)
m_pStream)->PutNextDirEntry(Name) );
704 wxArchiveEntry *pEntry = NULL;
708 pEntry =
new wxZipEntry(Name);
710 ((wxZipEntry *)pEntry)->SetIsText(bBinary ==
false);
712 #if wxCHECK_VERSION(3, 1, 1)
713 ((wxZipOutputStream *)
m_pStream)->SetFormat(wxZIP_FORMAT_ZIP64);
718 pEntry =
new wxTarEntry(Name);
721 if( ((wxArchiveOutputStream *)
m_pStream)->PutNextEntry(pEntry) )
737 return( ((wxArchiveEntry *)
m_Files[Index])->IsDir() );
748 if( ((wxArchiveInputStream *)
m_pStream)->OpenEntry(*(wxArchiveEntry *)
m_Files[Index]) )
766 if( !((wxArchiveEntry *)
m_Files[i])->GetName().Cmp(Name) )
783 wxString Name(((wxArchiveEntry *)
m_Files[Index])->GetName()); s = &Name;
803 const char Separator =
'\\';
805 const char Separator =
'/';
819 Directory += Separator;
860 #define UNZIP_BUFFER 4096
868 Stream.
Write(Buffer, 1, nBytes); Stream.
Flush();
884 return( wxFileName::DirExists(Directory.
c_str()) );
895 return( wxFileName::Mkdir(Directory.
c_str(), wxS_DIR_DEFAULT, bFullPath ? wxPATH_MKDIR_FULL : 0) );
906 return( wxDir::Remove(Directory.
c_str(), bRecursive ? wxPATH_RMDIR_RECURSIVE : 0) );
912 wxString cwd = wxFileName::GetCwd();
920 wxString fname = wxFileName::GetTempDir();
932 if( Dir.Open(Directory.
c_str()) )
936 if( Dir.GetFirst(&FileName, wxEmptyString, wxDIR_DIRS) )
942 while( Dir.GetNext(&FileName) );
961 if( Dir.Open(Directory.
c_str()) )
965 if( Dir.GetFirst(&FileName, wxEmptyString, wxDIR_FILES) )
974 while( Dir.GetNext(&FileName) );
991 return( wxFileExists(FileName.
c_str()) );
1010 return(
CSG_String(wxFileName::CreateTempFileName(Prefix.
c_str()).wc_str()) );
1019 wxFileName fn(full_Path.
c_str());
1023 wxString s(fn.GetFullName());
return(
CSG_String(&s) );
1026 wxString s(fn.GetName());
return( &s );
1032 wxString s(wxFileName(full_Path.
c_str()).GetPath(wxPATH_GET_VOLUME|wxPATH_GET_SEPARATOR));
1040 wxFileName fn(full_Path.
c_str());
1044 wxString s(fn.GetFullPath());
return( &s );
1050 wxFileName fn(full_Path.
c_str());
1052 fn.MakeRelativeTo(Directory.
c_str());
1054 wxString s(fn.GetFullPath());
return( &s );
1072 fn.SetExt (Extension.
c_str());
1079 wxString s(fn.GetFullPath());
return( &s );
1085 wxFileName a(wxString(Path1.
c_str())), b(wxString(Path2.
c_str()));
1087 return( a.SameAs(b) );
1099 if( FileName.
Length() > 0 )
1101 wxFileName fn(FileName.
c_str());
1103 fn.SetExt(Extension.
c_str());
1105 wxString s(fn.GetFullPath());
1118 wxFileName fn(FileName.
c_str());
1120 wxString s(fn.GetExt());
return( &s );
1135 return( wxGetEnv(Variable.
w_str(), NULL) );
1140 if( wxGetEnv(Variable.
w_str(), &s) )
1142 *Value = s.wc_str();
1153 return( wxSetEnv(Variable.
w_str(), Value.
w_str()) );