Fix computation of file:// urls from paths
--HG-- branch : WINDOWSPORT
This commit is contained in:
parent
a66209dc6e
commit
8022515a00
@ -1212,7 +1212,7 @@ void RclConfig::urlrewrite(const string& dbdir, string& url) const
|
|||||||
// This call always succeeds because the key comes from getNames()
|
// This call always succeeds because the key comes from getNames()
|
||||||
if (m_ptrans->get(*it, npath, dbdir)) {
|
if (m_ptrans->get(*it, npath, dbdir)) {
|
||||||
path = path.replace(0, it->size(), npath);
|
path = path.replace(0, it->size(), npath);
|
||||||
url = "file://" + path;
|
url = path_pathtofileurl(path);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -769,7 +769,7 @@ FsIndexer::processonefile(RclConfig *config,
|
|||||||
if (doc.fmtime.empty())
|
if (doc.fmtime.empty())
|
||||||
doc.fmtime = ascdate;
|
doc.fmtime = ascdate;
|
||||||
if (doc.url.empty())
|
if (doc.url.empty())
|
||||||
doc.url = cstr_fileu + fn;
|
doc.url = path_pathtofileurl(fn);
|
||||||
const string *fnp = 0;
|
const string *fnp = 0;
|
||||||
if (doc.ipath.empty()) {
|
if (doc.ipath.empty()) {
|
||||||
if (!doc.peekmeta(Rcl::Doc::keyfn, &fnp) || fnp->empty())
|
if (!doc.peekmeta(Rcl::Doc::keyfn, &fnp) || fnp->empty())
|
||||||
@ -865,7 +865,7 @@ FsIndexer::processonefile(RclConfig *config,
|
|||||||
fileDoc.meta[Rcl::Doc::keytcfn] = utf8fn;
|
fileDoc.meta[Rcl::Doc::keytcfn] = utf8fn;
|
||||||
fileDoc.haschildren = true;
|
fileDoc.haschildren = true;
|
||||||
fileDoc.mimetype = mimetype;
|
fileDoc.mimetype = mimetype;
|
||||||
fileDoc.url = cstr_fileu + fn;
|
fileDoc.url = path_pathtofileurl(fn);
|
||||||
if (m_havelocalfields)
|
if (m_havelocalfields)
|
||||||
setlocalfields(localfields, fileDoc);
|
setlocalfields(localfields, fileDoc);
|
||||||
char cbuf[100];
|
char cbuf[100];
|
||||||
|
|||||||
@ -22,6 +22,8 @@
|
|||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#include <sys/resource.h>
|
#include <sys/resource.h>
|
||||||
|
#else
|
||||||
|
#include <direct.h>
|
||||||
#endif
|
#endif
|
||||||
#include "safefcntl.h"
|
#include "safefcntl.h"
|
||||||
#include "safeunistd.h"
|
#include "safeunistd.h"
|
||||||
|
|||||||
@ -74,7 +74,7 @@ class DLFWImpl {
|
|||||||
fp = fopen(filename, (truncate) ? "w" : "a");
|
fp = fopen(filename, (truncate) ? "w" : "a");
|
||||||
if (fp) {
|
if (fp) {
|
||||||
setvbuf(fp, 0, _IOLBF, BUFSIZ);
|
setvbuf(fp, 0, _IOLBF, BUFSIZ);
|
||||||
#ifdef O_APPEND
|
#if defined(O_APPEND) && !defined(_WIN32)
|
||||||
{
|
{
|
||||||
int flgs = 0;
|
int flgs = 0;
|
||||||
fcntl(fileno(fp), F_GETFL, &flgs);
|
fcntl(fileno(fp), F_GETFL, &flgs);
|
||||||
|
|||||||
@ -22,6 +22,7 @@
|
|||||||
#include "safefcntl.h"
|
#include "safefcntl.h"
|
||||||
#include "safeunistd.h"
|
#include "safeunistd.h"
|
||||||
#include "dirent.h"
|
#include "dirent.h"
|
||||||
|
#include "cstr.h"
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#include "safewindows.h"
|
#include "safewindows.h"
|
||||||
#else
|
#else
|
||||||
@ -818,6 +819,17 @@ string fileurltolocalpath(string url)
|
|||||||
return 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)
|
bool urlisfileurl(const string& url)
|
||||||
{
|
{
|
||||||
return url.find("file://") == 0;
|
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
|
/// Test if path is root (x:/). root is defined by root/.. == root
|
||||||
extern bool path_isroot(const std::string& p);
|
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
|
/// Temporary file class
|
||||||
class TempFileInternal {
|
class TempFileInternal {
|
||||||
public:
|
public:
|
||||||
|
|||||||
@ -145,6 +145,7 @@
|
|||||||
<ClInclude Include="..\index\mimetype.h" />
|
<ClInclude Include="..\index\mimetype.h" />
|
||||||
<ClInclude Include="..\internfile\internfile.h" />
|
<ClInclude Include="..\internfile\internfile.h" />
|
||||||
<ClInclude Include="..\internfile\mh_symlink.h" />
|
<ClInclude Include="..\internfile\mh_symlink.h" />
|
||||||
|
<ClInclude Include="..\utils\cpuconf.h" />
|
||||||
<ClInclude Include="..\utils\debuglog.h" />
|
<ClInclude Include="..\utils\debuglog.h" />
|
||||||
<ClInclude Include="..\utils\execmd.h" />
|
<ClInclude Include="..\utils\execmd.h" />
|
||||||
<ClInclude Include="..\utils\md5.h" />
|
<ClInclude Include="..\utils\md5.h" />
|
||||||
@ -212,6 +213,7 @@
|
|||||||
<ClCompile Include="..\utils\circache.cpp" />
|
<ClCompile Include="..\utils\circache.cpp" />
|
||||||
<ClCompile Include="..\utils\conftree.cpp" />
|
<ClCompile Include="..\utils\conftree.cpp" />
|
||||||
<ClCompile Include="..\utils\copyfile.cpp" />
|
<ClCompile Include="..\utils\copyfile.cpp" />
|
||||||
|
<ClCompile Include="..\utils\cpuconf.cpp" />
|
||||||
<ClCompile Include="..\utils\debuglog.cpp" />
|
<ClCompile Include="..\utils\debuglog.cpp" />
|
||||||
<ClCompile Include="..\utils\fileudi.cpp" />
|
<ClCompile Include="..\utils\fileudi.cpp" />
|
||||||
<ClCompile Include="..\utils\fstreewalk.cpp" />
|
<ClCompile Include="..\utils\fstreewalk.cpp" />
|
||||||
|
|||||||
@ -90,6 +90,9 @@
|
|||||||
<ClInclude Include="..\utils\wipedir.h">
|
<ClInclude Include="..\utils\wipedir.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\utils\cpuconf.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="..\utils\smallut.cpp">
|
<ClCompile Include="..\utils\smallut.cpp">
|
||||||
@ -287,6 +290,9 @@
|
|||||||
<ClCompile Include="..\utils\strmatcher.cpp">
|
<ClCompile Include="..\utils\strmatcher.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\utils\cpuconf.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="ClassDiagram.cd" />
|
<None Include="ClassDiagram.cd" />
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user