From e479760ec8348c9f1733438c2f7b976922679885 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mart=C3=ADn=20Lucas=20Golini?= Date: Sat, 9 Sep 2023 17:17:59 -0300 Subject: [PATCH] Stop using FileSystem::fileCanWrite for write access check since it doesn't work on Windows. I couldn't find any reliable way to check this than simply trying to open a file as "wb". --- include/eepp/graphics/text.hpp | 2 +- src/eepp/graphics/text.cpp | 6 +++--- src/eepp/ui/abstract/uiabstracttableview.cpp | 2 +- src/eepp/ui/doc/textdocument.cpp | 2 +- src/tools/ecode/ecode.cpp | 4 ++-- src/tools/uieditor/uieditor.cpp | 2 +- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/include/eepp/graphics/text.hpp b/include/eepp/graphics/text.hpp index 793546b67..4730b170b 100644 --- a/include/eepp/graphics/text.hpp +++ b/include/eepp/graphics/text.hpp @@ -209,7 +209,7 @@ class EE_API Text { int mLargestLineCharCount; Color mShadowColor; Vector2f mShadowOffset{ PixelDensity::dpToPx( 1 ), PixelDensity::dpToPx( 1 ) }; - Uint32 mAlign; + Uint32 mAlign{ TEXT_ALIGN_LEFT }; Uint32 mFontHeight; Uint32 mTabWidth; diff --git a/src/eepp/graphics/text.cpp b/src/eepp/graphics/text.cpp index 4e0a7378e..6cc5fc74b 100644 --- a/src/eepp/graphics/text.cpp +++ b/src/eepp/graphics/text.cpp @@ -98,7 +98,7 @@ Text::Text() : mNumLines( 0 ), mLargestLineCharCount( 0 ), mShadowColor( Color( 0, 0, 0, 255 ) ), - mAlign( 0 ), + mAlign( TEXT_ALIGN_LEFT ), mFontHeight( 0 ), mTabWidth( 4 ) {} @@ -118,7 +118,7 @@ Text::Text( const String& string, Font* font, unsigned int characterSize ) : mNumLines( 0 ), mLargestLineCharCount( 0 ), mShadowColor( Color( 0, 0, 0, 255 ) ), - mAlign( 0 ), + mAlign( TEXT_ALIGN_LEFT ), mFontHeight( mFont->getFontHeight( mRealFontSize ) ), mTabWidth( 4 ) { if ( !mFont->isScalable() ) { @@ -142,7 +142,7 @@ Text::Text( Font* font, unsigned int characterSize ) : mNumLines( 0 ), mLargestLineCharCount( 0 ), mShadowColor( Color( 0, 0, 0, 255 ) ), - mAlign( 0 ), + mAlign( TEXT_ALIGN_LEFT ), mFontHeight( mFont->getFontHeight( mRealFontSize ) ), mTabWidth( 4 ) { if ( !mFont->isScalable() ) { diff --git a/src/eepp/ui/abstract/uiabstracttableview.cpp b/src/eepp/ui/abstract/uiabstracttableview.cpp index c9d5fad2d..f284d1ff5 100644 --- a/src/eepp/ui/abstract/uiabstracttableview.cpp +++ b/src/eepp/ui/abstract/uiabstracttableview.cpp @@ -37,7 +37,7 @@ Float UIAbstractTableView::getRowHeight() const { return mRowHeight != 0 ? mRowHeight : ( eeceil( columnData( 0 ).widget ? columnData( 0 ).widget->getPixelsSize().getHeight() - : 16 ) ); + : PixelDensity::dpToPx( 16 ) ) ); } void UIAbstractTableView::setRowHeight( const Float& rowHeight ) { diff --git a/src/eepp/ui/doc/textdocument.cpp b/src/eepp/ui/doc/textdocument.cpp index 9dbaed4d2..45ed5e886 100644 --- a/src/eepp/ui/doc/textdocument.cpp +++ b/src/eepp/ui/doc/textdocument.cpp @@ -524,7 +524,7 @@ TextDocument::LoadStatus TextDocument::reload() { bool TextDocument::save( const std::string& path ) { if ( path.empty() || mDefaultFileName == path ) return false; - if ( FileSystem::fileCanWrite( FileSystem::fileRemoveFileName( path ) ) ) { + if ( FileSystem::fileWrite( path, "" ) ) { IOStreamFile file( path, "wb" ); std::string oldFilePath( mFilePath ); URI oldFileURI( mFileURI ); diff --git a/src/tools/ecode/ecode.cpp b/src/tools/ecode/ecode.cpp index 704ff8175..b286e399d 100644 --- a/src/tools/ecode/ecode.cpp +++ b/src/tools/ecode/ecode.cpp @@ -362,7 +362,7 @@ UIFileDialog* App::saveFileDialog( UICodeEditor* editor, bool focusOnClose ) { if ( editor ) { std::string path( event->getNode()->asType()->getFullPath() ); if ( !path.empty() && !FileSystem::isDirectory( path ) && - FileSystem::fileCanWrite( FileSystem::fileRemoveFileName( path ) ) ) { + FileSystem::fileWrite( path, "" ) ) { if ( editor->getDocument().save( path ) ) { updateEditorState(); } else { @@ -2865,7 +2865,7 @@ void App::initProjectTreeView( std::string path, bool openClean ) { if ( FileSystem::fileExists( rpath ) ) { loadFileFromPath( rpath, false, nullptr, forcePosition ); - } else if ( FileSystem::fileCanWrite( folderPath ) ) { + } else if ( FileSystem::fileWrite( path, "" ) ) { loadFileFromPath( path, false, nullptr, forcePosition ); } diff --git a/src/tools/uieditor/uieditor.cpp b/src/tools/uieditor/uieditor.cpp index 719274d2d..50d2f0528 100644 --- a/src/tools/uieditor/uieditor.cpp +++ b/src/tools/uieditor/uieditor.cpp @@ -997,7 +997,7 @@ UIFileDialog* App::saveFileDialog( UICodeEditor* editor, bool focusOnClose ) { if ( editor ) { std::string path( event->getNode()->asType()->getFullPath() ); if ( !path.empty() && !FileSystem::isDirectory( path ) && - FileSystem::fileCanWrite( FileSystem::fileRemoveFileName( path ) ) ) { + FileSystem::fileWrite( path, "" ) ) { std::string oldPath( editor->getDocument().getFilePath() ); if ( editor->getDocument().save( path ) ) { editor->getDocument().setDeleteOnClose( false );