* support "." as parameter when creating a package, in order to
simplify creating a package for the contents of the current folder git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@40213 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -6,6 +6,7 @@
|
|||||||
|
|
||||||
#include "package.h"
|
#include "package.h"
|
||||||
|
|
||||||
|
#include <dirent.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <getopt.h>
|
#include <getopt.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@@ -74,10 +75,30 @@ printf("Init(): %s\n", strerror(error));
|
|||||||
|
|
||||||
// add files
|
// add files
|
||||||
for (int i = 0; i < fileNameCount; i++) {
|
for (int i = 0; i < fileNameCount; i++) {
|
||||||
error = packageWriter.AddEntry(fileNames[i]);
|
if (strcmp(fileNames[i], ".") == 0) {
|
||||||
|
DIR* dir = opendir (".");
|
||||||
|
if (dir == NULL) {
|
||||||
|
fprintf(stderr, "Error: Failed to opendir '.': %s\n",
|
||||||
|
strerror(errno));
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
while (dirent* entry = readdir(dir)) {
|
||||||
|
if (strcmp(entry->d_name, ".") == 0
|
||||||
|
|| strcmp(entry->d_name, "..") == 0)
|
||||||
|
continue;
|
||||||
|
error = packageWriter.AddEntry(entry->d_name);
|
||||||
|
printf("AddEntry(\"%s\"): %s\n", entry->d_name, strerror(error));
|
||||||
|
if (error != B_OK)
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
closedir (dir);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
error = packageWriter.AddEntry(fileNames[i]);
|
||||||
printf("AddEntry(\"%s\"): %s\n", fileNames[i], strerror(error));
|
printf("AddEntry(\"%s\"): %s\n", fileNames[i], strerror(error));
|
||||||
if (error != B_OK)
|
if (error != B_OK)
|
||||||
return 1;
|
return 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// write the package
|
// write the package
|
||||||
|
|||||||
Reference in New Issue
Block a user