Skip to content

Commit

Permalink
Format text
Browse files Browse the repository at this point in the history
  • Loading branch information
nstrahl committed Mar 21, 2024
1 parent a146327 commit 8300b9a
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 29 deletions.
4 changes: 2 additions & 2 deletions mdal/frmts/mdal_selafin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1290,9 +1290,9 @@ bool MDAL::SelafinFile::addDatasetGroup( MDAL::DatasetGroup *datasetGroup )
if ( datasetGroup->uri() == mFileName )
datasetGroup->mesh()->closeSource();

if ( !MDAL::deleteFile(mFileName) || !MDAL::renameFile(tempFileName, mFileName) )
if ( !MDAL::deleteFile( mFileName ) || !MDAL::renameFile( tempFileName, mFileName ) )
{
MDAL::deleteFile(tempFileName);
MDAL::deleteFile( tempFileName );
throw MDAL::Error( MDAL_Status::Err_FailToWriteToDisk, "Unable to write dataset in file" );
}

Expand Down
30 changes: 15 additions & 15 deletions mdal/mdal_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,31 +102,31 @@ std::string MDAL::readFileToString( const std::string &filename )
return "";
}

bool MDAL::deleteFile(const std::string& path)
bool MDAL::deleteFile( const std::string &path )
{
if (MDAL::fileExists(path))
{
if ( MDAL::fileExists( path ) )
{
#ifdef _MSC_VER
std::wstring_convert< std::codecvt_utf8_utf16< wchar_t > > converter;
std::wstring wStr = converter.from_bytes(path);
return DeleteFileW(wStr.c_str()) != 0;
std::wstring_convert< std::codecvt_utf8_utf16< wchar_t > > converter;
std::wstring wStr = converter.from_bytes( path );
return DeleteFileW( wStr.c_str() ) != 0;
#else
return remove(path.c_str()) == 0;
return remove( path.c_str() ) == 0;
#endif
}
}

return false;
return false;
}

bool MDAL::renameFile(const std::string& from, const std::string& to)
bool MDAL::renameFile( const std::string &from, const std::string &to )
{
#ifdef _MSC_VER
std::wstring_convert< std::codecvt_utf8_utf16< wchar_t > > converter;
std::wstring wFrom = converter.from_bytes(from);
std::wstring wTo = converter.from_bytes(to);
return _wrename(wFrom.c_str(), wTo.c_str()) == 0;
std::wstring_convert< std::codecvt_utf8_utf16< wchar_t > > converter;
std::wstring wFrom = converter.from_bytes( from );
std::wstring wTo = converter.from_bytes( to );
return _wrename( wFrom.c_str(), wTo.c_str() ) == 0;
#else
return std::rename(from.c_str(), to.c_str()) == 0;
return std::rename( from.c_str(), to.c_str() ) == 0;
#endif
}

Expand Down
4 changes: 2 additions & 2 deletions mdal/mdal_utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,10 @@ namespace MDAL
std::string readFileToString( const std::string &filename );

//! Deletes a file. Returns true on success, false otherwise
bool deleteFile(const std::string& path);
bool deleteFile( const std::string &path );

//!renames a file. Returns true on success, false otherwise
bool renameFile(const std::string& from, const std::string& to);
bool renameFile( const std::string &from, const std::string &to );

// strings
enum ContainsBehaviour
Expand Down
20 changes: 10 additions & 10 deletions tests/mdal_testutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ void deleteFile( const std::string &path )
{
#ifdef _MSC_VER
std::wstring_convert< std::codecvt_utf8_utf16< wchar_t > > converter;
std::wstring wStr = converter.from_bytes(path);
DeleteFileW(wStr.c_str());
std::wstring wStr = converter.from_bytes( path );
DeleteFileW( wStr.c_str() );
#else
remove( path.c_str() );
#endif
Expand All @@ -72,17 +72,17 @@ void deleteFile( const std::string &path )
bool fileExists( const std::string &filename )
{
#ifdef _MSC_VER
std::ifstream in;
std::wstring_convert< std::codecvt_utf8_utf16< wchar_t > > converter;
std::wstring wStr = converter.from_bytes(filename);
in.open(wStr, std::ifstream::in | std::ifstream::binary);
if (!in.is_open())
return false;
std::ifstream in;
std::wstring_convert< std::codecvt_utf8_utf16< wchar_t > > converter;
std::wstring wStr = converter.from_bytes( filename );
in.open( wStr, std::ifstream::in | std::ifstream::binary );
if ( !in.is_open() )
return false;
#else
std::ifstream in(filename);
std::ifstream in( filename );
#endif

return in.good();
return in.good();
}

int getActive( MDAL_DatasetH dataset, int index )
Expand Down

0 comments on commit 8300b9a

Please sign in to comment.