[libcalamares] Get target path relative to host /
This commit is contained in:
parent
43eb664e7d
commit
1a85435372
@ -244,7 +244,7 @@ System::runCommand(
|
|||||||
}
|
}
|
||||||
|
|
||||||
QString
|
QString
|
||||||
System::createTargetFile( const QString& path, const QByteArray& contents )
|
System::targetPath( const QString& path ) const
|
||||||
{
|
{
|
||||||
QString completePath;
|
QString completePath;
|
||||||
|
|
||||||
@ -265,6 +265,18 @@ System::createTargetFile( const QString& path, const QByteArray& contents )
|
|||||||
completePath = QStringLiteral( "/" ) + path;
|
completePath = QStringLiteral( "/" ) + path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return completePath;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString
|
||||||
|
System::createTargetFile( const QString& path, const QByteArray& contents ) const
|
||||||
|
{
|
||||||
|
QString completePath = targetPath( path );
|
||||||
|
if ( completePath.isEmpty() )
|
||||||
|
{
|
||||||
|
return QString();
|
||||||
|
}
|
||||||
|
|
||||||
QFile f( completePath );
|
QFile f( completePath );
|
||||||
if ( f.exists() )
|
if ( f.exists() )
|
||||||
{
|
{
|
||||||
|
@ -205,9 +205,27 @@ public:
|
|||||||
return targetEnvOutput( QStringList{ command }, output, workingPath, stdInput, timeoutSec );
|
return targetEnvOutput( QStringList{ command }, output, workingPath, stdInput, timeoutSec );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/** @brief Gets a path to a file in the target system, from the host.
|
||||||
|
*
|
||||||
|
* @param path Path to the file; this is interpreted
|
||||||
|
* from the root of the target system (whatever that may be,
|
||||||
|
* but / in the chroot, or / in OEM modes).
|
||||||
|
*
|
||||||
|
* @return The complete path to the target file, from
|
||||||
|
* the root of the host system, or empty on failure.
|
||||||
|
*
|
||||||
|
* For instance, during installation where the target root is
|
||||||
|
* mounted on /tmp/calamares-something, asking for targetPath("/etc/passwd")
|
||||||
|
* will give you /tmp/calamares-something/etc/passwd.
|
||||||
|
*
|
||||||
|
* No attempt is made to canonicalize anything, since paths might not exist.
|
||||||
|
*/
|
||||||
|
DLLEXPORT QString targetPath( const QString& path ) const;
|
||||||
|
|
||||||
/** @brief Create a (small-ish) file in the target system.
|
/** @brief Create a (small-ish) file in the target system.
|
||||||
*
|
*
|
||||||
* @param path Path to the file; this is **always** interpreted
|
* @param path Path to the file; this is interpreted
|
||||||
* from the root of the target system (whatever that may be,
|
* from the root of the target system (whatever that may be,
|
||||||
* but / in the chroot, or / in OEM modes).
|
* but / in the chroot, or / in OEM modes).
|
||||||
* @param contents Actual content of the file.
|
* @param contents Actual content of the file.
|
||||||
@ -215,9 +233,11 @@ public:
|
|||||||
* Will not overwrite files. Returns an empty string if the
|
* Will not overwrite files. Returns an empty string if the
|
||||||
* target file already exists.
|
* target file already exists.
|
||||||
*
|
*
|
||||||
* @return The complete canonical path to the target file, or empty on failure.
|
* @return The complete canonical path to the target file from the
|
||||||
|
* root of the host system, or empty on failure. (Here, it is
|
||||||
|
* possible to be canonical because the file exists).
|
||||||
*/
|
*/
|
||||||
QString createTargetFile( const QString& path, const QByteArray& contents );
|
DLLEXPORT QString createTargetFile( const QString& path, const QByteArray& contents ) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief getTotalMemoryB returns the total main memory, in bytes.
|
* @brief getTotalMemoryB returns the total main memory, in bytes.
|
||||||
|
Loading…
Reference in New Issue
Block a user