Files - Use T_FSPath

This commit is contained in:
Emmanuel BENOîT 2017-12-27 14:57:24 +01:00
parent 5497856be2
commit 424ba93472
3 changed files with 9 additions and 8 deletions

View file

@ -4,8 +4,8 @@
#ifndef _H_EBCL_FILES
#define _H_EBCL_FILES
#include <ebcl/Filesystem.hh>
#include <ebcl/Streams.hh>
#include <ebcl/Strings.hh>
namespace ebcl {
@ -21,7 +21,7 @@ enum class E_FileMode {
class T_File final
{
private:
T_String path_;
T_FSPath path_;
E_FileMode mode_;
FILE* file_;
size_t size_ , pos_;
@ -30,7 +30,7 @@ class T_File final
public:
// Construct from a file path. Does not open the file.
T_File( T_String const& path , E_FileMode mode );
T_File( T_FSPath const& path , E_FileMode mode );
// Move constructor and assignment
T_File( T_File&& other ) noexcept;
@ -49,7 +49,7 @@ class T_File final
// -------------------------------------------------------------------
// Get the path
T_String const& path( ) const noexcept;
T_FSPath const& path( ) const noexcept;
// Get the mode
E_FileMode mode( ) const noexcept;
@ -182,6 +182,6 @@ class T_FileOutputStream final : public A_OutputStream
M_CLASS_POINTERS( FileOutputStream );
}
} // namespace ebcl
#endif // _H_EBCL_FILES
#include <ebcl/inline/Files.hh>

View file

@ -29,7 +29,7 @@ inline void swap( T_File& lhs , T_File& rhs ) noexcept
/*---------------------------------------------------------------------------*/
inline T_String const& T_File::path( ) const noexcept
inline T_FSPath const& T_File::path( ) const noexcept
{
return path_;
}

View file

@ -13,7 +13,8 @@ T_File::T_File( )
: path_( ) , file_( nullptr )
{ }
T_File::T_File( T_String const& path , E_FileMode mode )
T_File::T_File( T_FSPath const& path ,
const E_FileMode mode )
: path_( path ) , mode_( mode ) , file_( nullptr )
{ }
@ -38,7 +39,7 @@ void T_File::open( )
}
// Copy file path to C string
const T_Buffer< char > path( path_.toOSString( ) );
const T_Buffer< char > path( path_.toString( ).toOSString( ) );
// Select the right mode
char const* const mode( ([this]() {