mirror of
https://github.com/audacity/linuxdeploy.git
synced 2026-02-04 20:36:11 -06:00
Don't require desktop file's path to exist
This commit is contained in:
parent
aaaca8b321
commit
574a883733
@ -33,7 +33,8 @@ namespace linuxdeploy {
|
||||
DesktopFile();
|
||||
|
||||
// construct from existing desktop file
|
||||
// file must exist, otherwise std::runtime_error is thrown
|
||||
// if the file exists, it will be read using DesktopFileReader
|
||||
// if reading fails, exceptions will be thrown (see DesktopFileReader for more information)
|
||||
explicit DesktopFile(const boost::filesystem::path& path);
|
||||
|
||||
// construct by reading an existing stream
|
||||
|
||||
@ -36,8 +36,10 @@ namespace linuxdeploy {
|
||||
DesktopFile::DesktopFile() : d(std::make_shared<PrivateData>()) {}
|
||||
|
||||
DesktopFile::DesktopFile(const bf::path& path) : DesktopFile() {
|
||||
// will throw exceptions in case of issues
|
||||
read(path);
|
||||
if (bf::exists(path)) {
|
||||
// will throw exceptions in case of issues
|
||||
read(path);
|
||||
}
|
||||
};
|
||||
|
||||
DesktopFile::DesktopFile(std::istream& is) : DesktopFile() {
|
||||
|
||||
@ -66,7 +66,8 @@ TEST_F(DesktopFileFixture, testDefaultConstructor) {
|
||||
}
|
||||
|
||||
TEST_F(DesktopFileFixture, testPathConstructor) {
|
||||
EXPECT_THROW(DesktopFile("/a/b/c/d/e/f/g/h/1/2/3/4/5/6/7/8"), std::invalid_argument);
|
||||
DesktopFile nonExistingPath("/a/b/c/d/e/f/g/h/1/2/3/4/5/6/7/8");
|
||||
EXPECT_TRUE(nonExistingPath.isEmpty());
|
||||
|
||||
DesktopFile emptyFile("/dev/null");
|
||||
EXPECT_TRUE(emptyFile.isEmpty());
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user