[libcalamares] Add convenience createTargetParentDirs()

This commit is contained in:
Adriaan de Groot 2020-02-07 16:09:02 +01:00
parent 6ede9f2c7c
commit 240fe2a564
2 changed files with 15 additions and 2 deletions

View File

@ -378,6 +378,12 @@ System::createTargetDirs( const QString& path ) const
return d.mkpath( target ); // This re-does everything starting from the **host** / return d.mkpath( target ); // This re-does everything starting from the **host** /
} }
bool
System::createTargetParentDirs( const QString& filePath ) const
{
return createTargetDirs( QFileInfo( filePath ).dir().path() );
}
QPair< quint64, float > QPair< quint64, float >
System::getTotalMemoryB() const System::getTotalMemoryB() const

View File

@ -255,17 +255,24 @@ public:
*/ */
DLLEXPORT void removeTargetFile( const QString& path ) const; DLLEXPORT void removeTargetFile( const QString& path ) const;
/** @brief Ensure that the directories above @p path exist /** @brief Ensure that the directory @p path exists
* *
* @param path a full pathname to a desired directory. * @param path a full pathname to a desired directory.
* *
* All the directory components including the last path component are * All the directory components including the last path component are
* created, as needed, with 0755 permissions. Returns true on success. * created, as needed. Returns true on success.
* *
* @see QDir::mkpath * @see QDir::mkpath
*/ */
DLLEXPORT bool createTargetDirs( const QString& path ) const; DLLEXPORT bool createTargetDirs( const QString& path ) const;
/** @brief Convenience to create parent directories of a file path.
*
* Creates all the parent directories until the last
* component of @p filePath . @see createTargetDirs()
*/
DLLEXPORT bool createTargetParentDirs( const QString& filePath ) const;
/** /**
* @brief getTotalMemoryB returns the total main memory, in bytes. * @brief getTotalMemoryB returns the total main memory, in bytes.
* *