Fix computation of file:// urls from paths
--HG-- branch : WINDOWSPORT
This commit is contained in:
@@ -74,7 +74,7 @@ class DLFWImpl {
|
||||
fp = fopen(filename, (truncate) ? "w" : "a");
|
||||
if (fp) {
|
||||
setvbuf(fp, 0, _IOLBF, BUFSIZ);
|
||||
#ifdef O_APPEND
|
||||
#if defined(O_APPEND) && !defined(_WIN32)
|
||||
{
|
||||
int flgs = 0;
|
||||
fcntl(fileno(fp), F_GETFL, &flgs);
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#include "safefcntl.h"
|
||||
#include "safeunistd.h"
|
||||
#include "dirent.h"
|
||||
#include "cstr.h"
|
||||
#ifdef _WIN32
|
||||
#include "safewindows.h"
|
||||
#else
|
||||
@@ -818,6 +819,17 @@ string fileurltolocalpath(string url)
|
||||
return url;
|
||||
}
|
||||
|
||||
string path_pathtofileurl(const string& path)
|
||||
{
|
||||
// We're supposed to receive a canonic absolute path, but on windows we
|
||||
// may need to add a '/' in front of the drive spec
|
||||
string url(cstr_fileu);
|
||||
if (path.empty() || path[0] != '/')
|
||||
url.push_back('/');
|
||||
url += path;
|
||||
return url;
|
||||
}
|
||||
|
||||
bool urlisfileurl(const string& url)
|
||||
{
|
||||
return url.find("file://") == 0;
|
||||
|
||||
@@ -109,6 +109,9 @@ extern bool path_isabsolute(const std::string& s);
|
||||
/// Test if path is root (x:/). root is defined by root/.. == root
|
||||
extern bool path_isroot(const std::string& p);
|
||||
|
||||
/// Turn absolute path into file:// url
|
||||
extern std::string path_pathtofileurl(const std::string& path);
|
||||
|
||||
/// Temporary file class
|
||||
class TempFileInternal {
|
||||
public:
|
||||
|
||||
Reference in New Issue
Block a user