#ifndef _WX_FILENAME_H_
#define _WX_FILENAME_H_
-#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
- #pragma interface "filename.h"
-#endif
-
-#ifndef WX_PRECOMP
- #include "wx/string.h"
- #include "wx/arrstr.h"
-#endif
-
/*
TODO:
2. more file operations:
a) chmod()
b) [acm]time() - get and set
- c) file size
- d) file permissions with readable accessors for most common bits
+ c) file permissions with readable accessors for most common bits
such as IsReadable() &c
- e) rename()?
+ d) rename()?
3. SameFileAs() function to compare inodes under Unix
*/
-// ridiculously enough, this will replace DirExists with wxDirExists etc
+#include "wx/arrstr.h"
#include "wx/filefn.h"
#include "wx/datetime.h"
+#include "wx/intl.h"
#if wxUSE_FILE
class WXDLLIMPEXP_BASE wxFile;
wxPATH_MKDIR_FULL = 0x0001 // create directories recursively
};
+// error code of wxFileName::GetSize()
+extern wxULongLong wxInvalidSize;
+
+
// ----------------------------------------------------------------------------
// wxFileName: encapsulates a file path
// ----------------------------------------------------------------------------
bool IsOk() const
{
// we're fine if we have the path or the name or if we're a root dir
- return m_dirs.size() != 0 || !m_name.IsEmpty() || !m_relative ||
+ return m_dirs.size() != 0 || !m_name.empty() || !m_relative ||
!m_ext.empty() || m_hasExt;
}
void RemoveLastDir() { RemoveDir(GetDirCount() - 1); }
// Other accessors
- void SetExt( const wxString &ext ) { m_ext = ext; m_hasExt = true; }
- void SetNoExt() { m_ext = wxEmptyString; m_hasExt = false; }
+ void SetExt( const wxString &ext ) { m_ext = ext; m_hasExt = !m_ext.empty(); }
+ void ClearExt() { m_ext = wxEmptyString; m_hasExt = false; }
+ void SetEmptyExt() { m_ext = wxT(""); m_hasExt = true; }
wxString GetExt() const { return m_ext; }
bool HasExt() const { return m_hasExt; }
wxString *path,
wxPathFormat format = wxPATH_NATIVE);
+ // Filesize
+
+ // returns the size of the given filename
+ wxULongLong GetSize() const;
+ static wxULongLong GetSize(const wxString &file);
+
+ // returns the size in a human readable form
+ wxString GetHumanReadableSize(const wxString &nullsize = wxGetTranslation(_T("Not available")),
+ int precision = 1) const;
+ static wxString GetHumanReadableSize(const wxULongLong &sz,
+ const wxString &nullsize = wxGetTranslation(_T("Not available")),
+ int precision = 1);
+
+
// deprecated methods, don't use any more
// --------------------------------------
{ return GetPath(withSep ? wxPATH_GET_SEPARATOR : 0, format); }
#endif
wxString GetPathWithSep(wxPathFormat format = wxPATH_NATIVE ) const
- { return GetPath(wxPATH_GET_SEPARATOR, format); }
+ { return GetPath(wxPATH_GET_VOLUME | wxPATH_GET_SEPARATOR, format); }
private:
// check whether this dir is valid for Append/Prepend/InsertDir()