fs/Path: rename to AllocatedPath

The new class Path only holds a string pointer without being
responsible for allocation/deallocation.  The FileSystem.hxx library
accepts Path arguments instead of AllocatedPath, to avoid forcing
callers to allocate another string object.
This commit is contained in:
Max Kellermann
2013-10-17 21:59:35 +02:00
parent b3611524f4
commit abfbd55305
51 changed files with 621 additions and 394 deletions

View File

@@ -19,26 +19,28 @@
#include "config.h"
#include "FileSystem.hxx"
#include "AllocatedPath.hxx"
#include "Limits.hxx"
#include <errno.h>
Path ReadLink(const Path &path)
AllocatedPath
ReadLink(Path path)
{
#ifdef WIN32
(void)path;
errno = EINVAL;
return Path::Null();
return AllocatedPath::Null();
#else
char buffer[MPD_PATH_MAX];
ssize_t size = readlink(path.c_str(), buffer, MPD_PATH_MAX);
if (size < 0)
return Path::Null();
return AllocatedPath::Null();
if (size_t(size) >= MPD_PATH_MAX) {
errno = ENOMEM;
return Path::Null();
return AllocatedPath::Null();
}
buffer[size] = '\0';
return Path::FromFS(buffer);
return AllocatedPath::FromFS(buffer);
#endif
}