2012-04-23 03:14:34 +02:00
|
|
|
//
|
|
|
|
// Path_WIN32U.cpp
|
|
|
|
//
|
|
|
|
// $Id: //poco/1.4/Foundation/src/Path_WINCE.cpp#1 $
|
|
|
|
//
|
|
|
|
// Library: Foundation
|
|
|
|
// Package: Filesystem
|
|
|
|
// Module: Path
|
|
|
|
//
|
|
|
|
// Copyright (c) 2006-2010, Applied Informatics Software Engineering GmbH.
|
|
|
|
// and Contributors.
|
|
|
|
//
|
2014-05-04 21:02:42 +02:00
|
|
|
// SPDX-License-Identifier: BSL-1.0
|
2012-04-23 03:14:34 +02:00
|
|
|
//
|
|
|
|
|
|
|
|
|
|
|
|
#include "Poco/Path_WINCE.h"
|
|
|
|
#include "Poco/Environment_WINCE.h"
|
|
|
|
#include "Poco/UnicodeConverter.h"
|
|
|
|
#include "Poco/Buffer.h"
|
|
|
|
#include "Poco/Environment.h"
|
|
|
|
#include "Poco/Exception.h"
|
|
|
|
#include "Poco/UnWindows.h"
|
|
|
|
|
|
|
|
|
|
|
|
namespace Poco {
|
|
|
|
|
|
|
|
|
|
|
|
std::string PathImpl::currentImpl()
|
|
|
|
{
|
|
|
|
return("\\");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
std::string PathImpl::homeImpl()
|
|
|
|
{
|
|
|
|
return("\\");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-12-14 19:09:23 +01:00
|
|
|
std::string PathImpl::systemImpl()
|
2012-04-23 03:14:34 +02:00
|
|
|
{
|
2012-12-14 19:09:23 +01:00
|
|
|
return("\\");
|
2012-04-23 03:14:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
std::string PathImpl::nullImpl()
|
|
|
|
{
|
|
|
|
return "NUL:";
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-03-17 14:36:17 +01:00
|
|
|
std::string PathImpl::tempImpl()
|
|
|
|
{
|
|
|
|
return "\\Temp\\";
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-04-23 03:14:34 +02:00
|
|
|
std::string PathImpl::expandImpl(const std::string& path)
|
|
|
|
{
|
|
|
|
std::string result;
|
|
|
|
std::string::const_iterator it = path.begin();
|
|
|
|
std::string::const_iterator end = path.end();
|
|
|
|
while (it != end)
|
|
|
|
{
|
|
|
|
if (*it == '%')
|
|
|
|
{
|
|
|
|
++it;
|
|
|
|
if (it != end && *it == '%')
|
|
|
|
{
|
|
|
|
result += '%';
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
std::string var;
|
|
|
|
while (it != end && *it != '%') var += *it++;
|
|
|
|
if (it != end) ++it;
|
|
|
|
result += Environment::get(var, "");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else result += *it++;
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void PathImpl::listRootsImpl(std::vector<std::string>& roots)
|
|
|
|
{
|
|
|
|
roots.clear();
|
|
|
|
roots.push_back("\\");
|
|
|
|
|
|
|
|
WIN32_FIND_DATAW fd;
|
|
|
|
HANDLE hFind = FindFirstFileW(L"\\*.*", &fd);
|
|
|
|
if (hFind != INVALID_HANDLE_VALUE)
|
|
|
|
{
|
|
|
|
do
|
|
|
|
{
|
|
|
|
if ((fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) &&
|
|
|
|
(fd.dwFileAttributes & FILE_ATTRIBUTE_TEMPORARY))
|
|
|
|
{
|
|
|
|
std::wstring name(fd.cFileName);
|
|
|
|
name += L"\\Vol:";
|
|
|
|
HANDLE h = CreateFileW(name.c_str(), GENERIC_READ|GENERIC_WRITE, 0, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
|
|
|
|
if (h != INVALID_HANDLE_VALUE)
|
|
|
|
{
|
|
|
|
// its a device volume
|
|
|
|
CloseHandle(h);
|
|
|
|
std::string name;
|
|
|
|
UnicodeConverter::toUTF8(fd.cFileName, name);
|
|
|
|
std::string root = "\\" + name;
|
|
|
|
roots.push_back(root);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
while (FindNextFileW(hFind, &fd));
|
|
|
|
FindClose(hFind);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
} // namespace Poco
|