ENH: Better error on file perm or time failure
This improves the error message produced during installation when CMake cannot set file modification time or permissions.
This commit is contained in:
parent
f180a834bf
commit
bc6eec18dc
|
@ -1000,6 +1000,18 @@ public:
|
||||||
this->Manifest += file.substr(this->DestDirLength);
|
this->Manifest += file.substr(this->DestDirLength);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool SetPermissions(const char* toFile, mode_t permissions)
|
||||||
|
{
|
||||||
|
if(permissions && !cmSystemTools::SetPermissions(toFile, permissions))
|
||||||
|
{
|
||||||
|
cmOStringStream e;
|
||||||
|
e << "INSTALL cannot set permissions on \"" << toFile << "\"";
|
||||||
|
this->FileCommand->SetError(e.str().c_str());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
// Translate an argument to a permissions bit.
|
// Translate an argument to a permissions bit.
|
||||||
bool CheckPermissions(std::string const& arg, mode_t& permissions)
|
bool CheckPermissions(std::string const& arg, mode_t& permissions)
|
||||||
{
|
{
|
||||||
|
@ -1138,7 +1150,7 @@ bool cmFileInstaller::InstallFile(const char* fromFile, const char* toFile)
|
||||||
if (!cmSystemTools::CopyFileTime(fromFile, toFile))
|
if (!cmSystemTools::CopyFileTime(fromFile, toFile))
|
||||||
{
|
{
|
||||||
cmOStringStream e;
|
cmOStringStream e;
|
||||||
e << "Problem setting modification time on file \"" << toFile << "\"";
|
e << "INSTALL cannot set modification time on \"" << toFile << "\"";
|
||||||
this->FileCommand->SetError(e.str().c_str());
|
this->FileCommand->SetError(e.str().c_str());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -1153,15 +1165,7 @@ bool cmFileInstaller::InstallFile(const char* fromFile, const char* toFile)
|
||||||
// that the source file permissions be used.
|
// that the source file permissions be used.
|
||||||
cmSystemTools::GetPermissions(fromFile, permissions);
|
cmSystemTools::GetPermissions(fromFile, permissions);
|
||||||
}
|
}
|
||||||
if(permissions && !cmSystemTools::SetPermissions(toFile, permissions))
|
return this->SetPermissions(toFile, permissions);
|
||||||
{
|
|
||||||
cmOStringStream e;
|
|
||||||
e << "Problem setting permissions on file \"" << toFile << "\"";
|
|
||||||
this->FileCommand->SetError(e.str().c_str());
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
|
@ -1230,13 +1234,8 @@ bool cmFileInstaller::InstallDirectory(const char* source,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the required permissions of the destination directory.
|
// Set the required permissions of the destination directory.
|
||||||
if(permissions_before &&
|
if(!this->SetPermissions(destination, permissions_before))
|
||||||
!cmSystemTools::SetPermissions(destination, permissions_before))
|
|
||||||
{
|
{
|
||||||
cmOStringStream e;
|
|
||||||
e << "Problem setting permissions on directory \""
|
|
||||||
<< destination << "\"";
|
|
||||||
this->FileCommand->SetError(e.str().c_str());
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1280,16 +1279,7 @@ bool cmFileInstaller::InstallDirectory(const char* source,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the requested permissions of the destination directory.
|
// Set the requested permissions of the destination directory.
|
||||||
if(permissions_after &&
|
return this->SetPermissions(destination, permissions_after);
|
||||||
!cmSystemTools::SetPermissions(destination, permissions_after))
|
|
||||||
{
|
|
||||||
cmOStringStream e;
|
|
||||||
e << "Problem setting permissions on directory \"" << destination << "\"";
|
|
||||||
this->FileCommand->SetError(e.str().c_str());
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
|
|
Loading…
Reference in New Issue