RemoteDrawingEngine: Reduce RP_READ_BITMAP result timeout.
[haiku.git] / src / bin / package / PackageWritingUtils.cpp
blob25cbe669e7eaf46b168f5c9ce8170362502424f1
1 /*
2 * Copyright 2011, Ingo Weinhold, ingo_weinhold@gmx.de.
3 * Distributed under the terms of the MIT License.
4 */
7 #include "PackageWritingUtils.h"
9 #include <dirent.h>
10 #include <errno.h>
11 #include <stdio.h>
12 #include <string.h>
14 #include <package/hpkg/HPKGDefs.h>
16 #include <AutoDeleter.h>
19 status_t
20 add_current_directory_entries(BPackageWriter& packageWriter,
21 BPackageWriterListener& listener, bool skipPackageInfo)
23 // open the current directory
24 DIR* dir = opendir(".");
25 if (dir == NULL) {
26 listener.PrintError("Error: Failed to opendir '.': %s\n",
27 strerror(errno));
28 return errno;
30 CObjectDeleter<DIR, int> dirCloser(dir, &closedir);
32 while (dirent* entry = readdir(dir)) {
33 // skip "." and ".."
34 if (strcmp(entry->d_name, ".") == 0 || strcmp(entry->d_name, "..") == 0)
35 continue;
37 // skip the .PackageInfo, if requested
38 if (skipPackageInfo
39 && strcmp(entry->d_name,
40 BPackageKit::BHPKG::B_HPKG_PACKAGE_INFO_FILE_NAME) == 0) {
41 continue;
44 status_t error = packageWriter.AddEntry(entry->d_name);
45 if (error != B_OK)
46 return error;
49 return B_OK;