mirror of
https://github.com/pocoproject/poco.git
synced 2025-01-30 14:28:50 +01:00
trunk/branch integration: source indentation
This commit is contained in:
parent
24a844d68b
commit
a535226b86
@ -37,7 +37,9 @@
|
|||||||
#include "Poco/TemporaryFile.h"
|
#include "Poco/TemporaryFile.h"
|
||||||
#include "Poco/Path.h"
|
#include "Poco/Path.h"
|
||||||
#include "Poco/Exception.h"
|
#include "Poco/Exception.h"
|
||||||
|
#if !defined(POCO_VXWORKS)
|
||||||
#include "Poco/Process.h"
|
#include "Poco/Process.h"
|
||||||
|
#endif
|
||||||
#include "Poco/Mutex.h"
|
#include "Poco/Mutex.h"
|
||||||
#include <set>
|
#include <set>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
@ -57,13 +59,13 @@ public:
|
|||||||
{
|
{
|
||||||
for (std::set<std::string>::iterator it = _files.begin(); it != _files.end(); ++it)
|
for (std::set<std::string>::iterator it = _files.begin(); it != _files.end(); ++it)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
File f(*it);
|
File f(*it);
|
||||||
if (f.exists())
|
if (f.exists())
|
||||||
f.remove(true);
|
f.remove(true);
|
||||||
}
|
}
|
||||||
catch (Exception&)
|
catch (Exception&)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -83,12 +85,16 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
TemporaryFile::TemporaryFile(): File(tempName()), _keep(false)
|
TemporaryFile::TemporaryFile():
|
||||||
|
File(tempName()),
|
||||||
|
_keep(false)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TemporaryFile::TemporaryFile(const std::string& tempDir): File(tempName(tempDir)), _keep(false)
|
TemporaryFile::TemporaryFile(const std::string& tempDir):
|
||||||
|
File(tempName(tempDir)),
|
||||||
|
_keep(false)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -122,26 +128,40 @@ void TemporaryFile::keepUntilExit()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
static TempFileCollector fc;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void TemporaryFile::registerForDeletion(const std::string& path)
|
void TemporaryFile::registerForDeletion(const std::string& path)
|
||||||
{
|
{
|
||||||
static TempFileCollector fc;
|
fc.registerFile(path);
|
||||||
fc.registerFile(path);
|
}
|
||||||
|
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
static FastMutex mutex;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::string TemporaryFile::tempName(const std::string& tempDir)
|
std::string TemporaryFile::tempName(const std::string& tempDir)
|
||||||
{
|
{
|
||||||
std::ostringstream name;
|
std::ostringstream name;
|
||||||
static FastMutex mutex;
|
static unsigned long count = 0;
|
||||||
static unsigned long count = 0;
|
mutex.lock();
|
||||||
mutex.lock();
|
unsigned long n = count++;
|
||||||
unsigned long n = count++;
|
mutex.unlock();
|
||||||
mutex.unlock();
|
name << (tempDir.empty() ? Path::temp() : tempDir);
|
||||||
name << (tempDir.empty() ? Path::temp() : tempDir);
|
#if defined(POCO_VXWORKS)
|
||||||
name << "tmp" << Process::id();
|
name << "tmp";
|
||||||
for (int i = 0; i < 6; ++i)
|
#else
|
||||||
{
|
name << "tmp" << Process::id();
|
||||||
name << char('a' + (n % 26));
|
#endif
|
||||||
|
for (int i = 0; i < 6; ++i)
|
||||||
|
{
|
||||||
|
name << char('a' + (n % 26));
|
||||||
n /= 26;
|
n /= 26;
|
||||||
}
|
}
|
||||||
return name.str();
|
return name.str();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user