2 * Copyright 2015, Axel Dörfler, axeld@pinc-software.de.
3 * Distributed under the terms of the MIT License.
7 #include "AbstractEmptyDirectoryJob.h"
11 #include <Directory.h>
15 AbstractEmptyDirectoryJob::AbstractEmptyDirectoryJob(const BString
& name
)
23 AbstractEmptyDirectoryJob::CreateAndEmpty(const char* path
) const
26 if (!entry
.Exists()) {
27 create_directory(path
, 0777);
29 status_t status
= entry
.SetTo(path
);
31 fprintf(stderr
, "Cannot create directory \"%s\": %s\n", path
,
37 return _EmptyDirectory(entry
, false);
42 AbstractEmptyDirectoryJob::_EmptyDirectory(BEntry
& directoryEntry
,
45 BDirectory
directory(&directoryEntry
);
47 while (directory
.GetNextEntry(&entry
) == B_OK
) {
48 if (entry
.IsDirectory())
49 _EmptyDirectory(entry
, true);
54 return remove
? directoryEntry
.Remove() : B_OK
;