mirror of
https://github.com/pocoproject/poco.git
synced 2024-12-15 11:30:59 +01:00
parent
a47ceecab2
commit
b00e48f35d
@ -45,6 +45,7 @@ File::File()
|
||||
|
||||
File::File(const std::string& rPath): FileImpl(rPath)
|
||||
{
|
||||
poco_assert(std::char_traits<char>::length(rPath.data()) == rPath.size());
|
||||
}
|
||||
|
||||
|
||||
@ -77,6 +78,7 @@ File& File::operator = (const File& file)
|
||||
|
||||
File& File::operator = (const std::string& rPath)
|
||||
{
|
||||
poco_assert(std::char_traits<char>::length(rPath.data()) == rPath.size());
|
||||
setPathImpl(rPath);
|
||||
return *this;
|
||||
}
|
||||
@ -212,6 +214,7 @@ File& File::setExecutable(bool flag)
|
||||
|
||||
void File::copyTo(const std::string& rPath) const
|
||||
{
|
||||
poco_assert(std::char_traits<char>::length(rPath.data()) == rPath.size());
|
||||
Path src(getPathImpl());
|
||||
Path dest(rPath);
|
||||
File destFile(rPath);
|
||||
@ -229,6 +232,7 @@ void File::copyTo(const std::string& rPath) const
|
||||
|
||||
void File::copyDirectory(const std::string& rPath) const
|
||||
{
|
||||
poco_assert(std::char_traits<char>::length(rPath.data()) == rPath.size());
|
||||
File target(rPath);
|
||||
target.createDirectories();
|
||||
|
||||
@ -245,6 +249,7 @@ void File::copyDirectory(const std::string& rPath) const
|
||||
|
||||
void File::moveTo(const std::string& rPath)
|
||||
{
|
||||
poco_assert(std::char_traits<char>::length(rPath.data()) == rPath.size());
|
||||
copyTo(rPath);
|
||||
remove(true);
|
||||
setPathImpl(rPath);
|
||||
@ -253,6 +258,7 @@ void File::moveTo(const std::string& rPath)
|
||||
|
||||
void File::renameTo(const std::string& rPath)
|
||||
{
|
||||
poco_assert(std::char_traits<char>::length(rPath.data()) == rPath.size());
|
||||
renameToImpl(rPath);
|
||||
setPathImpl(rPath);
|
||||
}
|
||||
|
@ -53,12 +53,14 @@ Path::Path(bool absolutePath): _absolute(absolutePath)
|
||||
|
||||
Path::Path(const std::string& path)
|
||||
{
|
||||
poco_assert(std::char_traits<char>::length(path.data()) == path.size());
|
||||
assign(path);
|
||||
}
|
||||
|
||||
|
||||
Path::Path(const std::string& path, Style style)
|
||||
{
|
||||
poco_assert(std::char_traits<char>::length(path.data()) == path.size());
|
||||
assign(path, style);
|
||||
}
|
||||
|
||||
@ -95,7 +97,8 @@ Path::Path(const Path& rParent, const std::string& fileName):
|
||||
_version(rParent._version),
|
||||
_dirs(rParent._dirs),
|
||||
_absolute(rParent._absolute)
|
||||
{
|
||||
{
|
||||
poco_assert(std::char_traits<char>::length(fileName.data()) == fileName.size());
|
||||
makeDirectory();
|
||||
_name = fileName;
|
||||
}
|
||||
@ -139,6 +142,7 @@ Path& Path::operator = (const Path& path)
|
||||
|
||||
Path& Path::operator = (const std::string& path)
|
||||
{
|
||||
poco_assert(std::char_traits<char>::length(path.data()) == path.size());
|
||||
return assign(path);
|
||||
}
|
||||
|
||||
@ -255,6 +259,7 @@ std::string Path::toString(Style style) const
|
||||
|
||||
bool Path::tryParse(const std::string& path)
|
||||
{
|
||||
poco_assert(std::char_traits<char>::length(path.data()) == path.size());
|
||||
try
|
||||
{
|
||||
Path p;
|
||||
@ -271,6 +276,7 @@ bool Path::tryParse(const std::string& path)
|
||||
|
||||
bool Path::tryParse(const std::string& path, Style style)
|
||||
{
|
||||
poco_assert(std::char_traits<char>::length(path.data()) == path.size());
|
||||
try
|
||||
{
|
||||
Path p;
|
||||
@ -287,6 +293,7 @@ bool Path::tryParse(const std::string& path, Style style)
|
||||
|
||||
Path& Path::parseDirectory(const std::string& path)
|
||||
{
|
||||
poco_assert(std::char_traits<char>::length(path.data()) == path.size());
|
||||
assign(path);
|
||||
return makeDirectory();
|
||||
}
|
||||
@ -294,6 +301,7 @@ Path& Path::parseDirectory(const std::string& path)
|
||||
|
||||
Path& Path::parseDirectory(const std::string& path, Style style)
|
||||
{
|
||||
poco_assert(std::char_traits<char>::length(path.data()) == path.size());
|
||||
assign(path, style);
|
||||
return makeDirectory();
|
||||
}
|
||||
@ -434,6 +442,7 @@ Path& Path::resolve(const Path& path)
|
||||
|
||||
Path& Path::setNode(const std::string& node)
|
||||
{
|
||||
poco_assert(std::char_traits<char>::length(node.data()) == node.size());
|
||||
_node = node;
|
||||
_absolute = _absolute || !node.empty();
|
||||
return *this;
|
||||
@ -442,6 +451,7 @@ Path& Path::setNode(const std::string& node)
|
||||
|
||||
Path& Path::setDevice(const std::string& device)
|
||||
{
|
||||
poco_assert(std::char_traits<char>::length(device.data()) == device.size());
|
||||
_device = device;
|
||||
_absolute = _absolute || !device.empty();
|
||||
return *this;
|
||||
@ -472,6 +482,7 @@ const std::string& Path::operator [] (int n) const
|
||||
|
||||
Path& Path::pushDirectory(const std::string& dir)
|
||||
{
|
||||
poco_assert(std::char_traits<char>::length(dir.data()) == dir.size());
|
||||
if (!dir.empty() && dir != ".")
|
||||
{
|
||||
#if defined(POCO_OS_FAMILY_VMS)
|
||||
@ -519,6 +530,7 @@ Path& Path::popFrontDirectory()
|
||||
|
||||
Path& Path::setFileName(const std::string& name)
|
||||
{
|
||||
poco_assert(std::char_traits<char>::length(name.data()) == name.size());
|
||||
_name = name;
|
||||
return *this;
|
||||
}
|
||||
@ -526,6 +538,7 @@ Path& Path::setFileName(const std::string& name)
|
||||
|
||||
Path& Path::setBaseName(const std::string& name)
|
||||
{
|
||||
poco_assert(std::char_traits<char>::length(name.data()) == name.size());
|
||||
std::string ext = getExtension();
|
||||
_name = name;
|
||||
if (!ext.empty())
|
||||
@ -549,6 +562,7 @@ std::string Path::getBaseName() const
|
||||
|
||||
Path& Path::setExtension(const std::string& extension)
|
||||
{
|
||||
poco_assert(std::char_traits<char>::length(extension.data()) == extension.size());
|
||||
_name = getBaseName();
|
||||
if (!extension.empty())
|
||||
{
|
||||
@ -646,6 +660,7 @@ std::string Path::null()
|
||||
|
||||
std::string Path::expand(const std::string& path)
|
||||
{
|
||||
poco_assert(std::char_traits<char>::length(path.data()) == path.size());
|
||||
return PathImpl::expandImpl(path);
|
||||
}
|
||||
|
||||
@ -658,6 +673,7 @@ void Path::listRoots(std::vector<std::string>& roots)
|
||||
|
||||
bool Path::find(StringVec::const_iterator it, StringVec::const_iterator end, const std::string& name, Path& path)
|
||||
{
|
||||
poco_assert(std::char_traits<char>::length(name.data()) == name.size());
|
||||
while (it != end)
|
||||
{
|
||||
#if defined(WIN32)
|
||||
|
@ -1471,7 +1471,11 @@ void PathTest::testRobustness()
|
||||
{
|
||||
int len = r.next(1024);
|
||||
std::string s;
|
||||
for (int i = 0; i < len; ++i) s += r.nextChar();
|
||||
while (s.size() < len)
|
||||
{
|
||||
char c = r.nextChar();
|
||||
if (c != 0) s += c;
|
||||
}
|
||||
try
|
||||
{
|
||||
Path p(s, Path::PATH_WINDOWS);
|
||||
|
Loading…
Reference in New Issue
Block a user