Make UEFI boot-platform build again
[haiku.git] / src / servers / launch / AbstractEmptyDirectoryJob.cpp
blob9929df69b1f324ef9360cacfd002cb4a0b1c9255
1 /*
2 * Copyright 2015, Axel Dörfler, axeld@pinc-software.de.
3 * Distributed under the terms of the MIT License.
4 */
7 #include "AbstractEmptyDirectoryJob.h"
9 #include <stdio.h>
11 #include <Directory.h>
12 #include <Entry.h>
15 AbstractEmptyDirectoryJob::AbstractEmptyDirectoryJob(const BString& name)
17 BJob(name)
22 status_t
23 AbstractEmptyDirectoryJob::CreateAndEmpty(const char* path) const
25 BEntry entry(path);
26 if (!entry.Exists()) {
27 create_directory(path, 0777);
29 status_t status = entry.SetTo(path);
30 if (status != B_OK) {
31 fprintf(stderr, "Cannot create directory \"%s\": %s\n", path,
32 strerror(status));
33 return status;
37 return _EmptyDirectory(entry, false);
41 status_t
42 AbstractEmptyDirectoryJob::_EmptyDirectory(BEntry& directoryEntry,
43 bool remove) const
45 BDirectory directory(&directoryEntry);
46 BEntry entry;
47 while (directory.GetNextEntry(&entry) == B_OK) {
48 if (entry.IsDirectory())
49 _EmptyDirectory(entry, true);
50 else
51 entry.Remove();
54 return remove ? directoryEntry.Remove() : B_OK;