diff --git a/src/bin/package/command_create.cpp b/src/bin/package/command_create.cpp index b397201f06..b0294c4e03 100644 --- a/src/bin/package/command_create.cpp +++ b/src/bin/package/command_create.cpp @@ -14,6 +14,7 @@ #include #include +#include #include #include @@ -120,6 +121,18 @@ command_create(int argc, const char* const* argv) return 1; } + BPath outputPath(packageFileName, NULL, true); + BPath inputPath(changeToDirectory, NULL, true); + BPath parent; + while (outputPath.GetParent(&parent) == B_OK) { + if (outputPath == inputPath) { + fprintf(stderr, "Error: output package can't be in the same " + "directory as input files."); + return 1; + } + outputPath = parent; + } + // create package BPackageWriterParameters writerParameters; writerParameters.SetCompressionLevel(compressionLevel);