BPicture: Fix archive constructor.
[haiku.git] / src / kits / package / TempfileManager.cpp
blob17295542cfd5d18efc8888bc1dac28e978550ca9
1 /*
2 * Copyright 2011, Haiku, Inc. All Rights Reserved.
3 * Distributed under the terms of the MIT License.
5 * Authors:
6 * Oliver Tappe <zooey@hirschkaefer.de>
7 */
10 #include <package/TempfileManager.h>
13 namespace BPackageKit {
15 namespace BPrivate {
18 const BString TempfileManager::kDefaultName = "tmp-pkgkit-file-";
21 TempfileManager::TempfileManager()
23 fNextNumber(1)
28 TempfileManager::~TempfileManager()
30 if (fBaseDirectory.InitCheck() != B_OK)
31 return;
33 fBaseDirectory.Rewind();
34 BEntry entry;
35 while (fBaseDirectory.GetNextEntry(&entry) == B_OK)
36 entry.Remove();
38 fBaseDirectory.GetEntry(&entry);
39 entry.Remove();
43 void
44 TempfileManager::SetBaseDirectory(const BDirectory& baseDirectory)
46 fBaseDirectory = baseDirectory;
50 BEntry
51 TempfileManager::Create(const BString& baseName)
53 BString name = BString(baseName) << atomic_add(&fNextNumber, 1);
55 return BEntry(&fBaseDirectory, name.String());
59 } // namespace BPrivate
61 } // namespace BPackageKit