2 * Copyright 2011, Haiku, Inc. All Rights Reserved.
3 * Distributed under the terms of the MIT License.
6 * Oliver Tappe <zooey@hirschkaefer.de>
10 #include <package/TempfileManager.h>
13 namespace BPackageKit
{
18 const BString
TempfileManager::kDefaultName
= "tmp-pkgkit-file-";
21 TempfileManager::TempfileManager()
28 TempfileManager::~TempfileManager()
30 if (fBaseDirectory
.InitCheck() != B_OK
)
33 fBaseDirectory
.Rewind();
35 while (fBaseDirectory
.GetNextEntry(&entry
) == B_OK
)
38 fBaseDirectory
.GetEntry(&entry
);
44 TempfileManager::SetBaseDirectory(const BDirectory
& baseDirectory
)
46 fBaseDirectory
= baseDirectory
;
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