shared
This commit is contained in:
parent
5353a22ce0
commit
0aed9b755e
@ -285,7 +285,7 @@ bool fsocc(const string& path, int *pc, long long *avmbs)
|
|||||||
ULARGE_INTEGER freebytesavail;
|
ULARGE_INTEGER freebytesavail;
|
||||||
ULARGE_INTEGER totalbytes;
|
ULARGE_INTEGER totalbytes;
|
||||||
if (!GetDiskFreeSpaceExA(path.c_str(), &freebytesavail,
|
if (!GetDiskFreeSpaceExA(path.c_str(), &freebytesavail,
|
||||||
&totalbytes, NULL)) {
|
&totalbytes, NULL)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (pc) {
|
if (pc) {
|
||||||
@ -315,11 +315,11 @@ bool fsocc(const string& path, int *pc, long long *avmbs)
|
|||||||
*avmbs = 0;
|
*avmbs = 0;
|
||||||
if (buf.f_bsize > 0) {
|
if (buf.f_bsize > 0) {
|
||||||
int ratio = buf.f_frsize > FSOCC_MB ? buf.f_frsize / FSOCC_MB :
|
int ratio = buf.f_frsize > FSOCC_MB ? buf.f_frsize / FSOCC_MB :
|
||||||
FSOCC_MB / buf.f_frsize;
|
FSOCC_MB / buf.f_frsize;
|
||||||
|
|
||||||
*avmbs = buf.f_frsize > FSOCC_MB ?
|
*avmbs = buf.f_frsize > FSOCC_MB ?
|
||||||
((long long)buf.f_bavail) * ratio :
|
((long long)buf.f_bavail) * ratio :
|
||||||
((long long)buf.f_bavail) / ratio;
|
((long long)buf.f_bavail) / ratio;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@ -527,7 +527,7 @@ bool path_isroot(const string& path)
|
|||||||
}
|
}
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
if (path.size() == 3 && isalpha(path[0]) && path[1] == ':' &&
|
if (path.size() == 3 && isalpha(path[0]) && path[1] == ':' &&
|
||||||
(path[2] == '/' || path[2] == '\\')) {
|
(path[2] == '/' || path[2] == '\\')) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -563,7 +563,7 @@ bool path_isabsolute(const string& path)
|
|||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|| path_isdriveabs(path)
|
|| path_isdriveabs(path)
|
||||||
#endif
|
#endif
|
||||||
)) {
|
)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@ -576,7 +576,7 @@ string path_absolute(const string& is)
|
|||||||
}
|
}
|
||||||
string s = is;
|
string s = is;
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
path_slashize(s);
|
path_slashize(s);
|
||||||
#endif
|
#endif
|
||||||
if (!path_isabsolute(s)) {
|
if (!path_isabsolute(s)) {
|
||||||
char buf[MAXPATHLEN];
|
char buf[MAXPATHLEN];
|
||||||
@ -621,7 +621,7 @@ string path_canon(const string& is, const string* cwd)
|
|||||||
stringToTokens(s, elems, "/");
|
stringToTokens(s, elems, "/");
|
||||||
vector<string> cleaned;
|
vector<string> cleaned;
|
||||||
for (vector<string>::const_iterator it = elems.begin();
|
for (vector<string>::const_iterator it = elems.begin();
|
||||||
it != elems.end(); it++) {
|
it != elems.end(); it++) {
|
||||||
if (*it == "..") {
|
if (*it == "..") {
|
||||||
if (!cleaned.empty()) {
|
if (!cleaned.empty()) {
|
||||||
cleaned.pop_back();
|
cleaned.pop_back();
|
||||||
@ -634,7 +634,7 @@ string path_canon(const string& is, const string* cwd)
|
|||||||
string ret;
|
string ret;
|
||||||
if (!cleaned.empty()) {
|
if (!cleaned.empty()) {
|
||||||
for (vector<string>::const_iterator it = cleaned.begin();
|
for (vector<string>::const_iterator it = cleaned.begin();
|
||||||
it != cleaned.end(); it++) {
|
it != cleaned.end(); it++) {
|
||||||
ret += "/";
|
ret += "/";
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
if (it == cleaned.begin() && path_strlookslikedrive(*it)) {
|
if (it == cleaned.begin() && path_strlookslikedrive(*it)) {
|
||||||
@ -763,22 +763,22 @@ string url_encode(const string& url, string::size_type offs)
|
|||||||
const char *h = "0123456789ABCDEF";
|
const char *h = "0123456789ABCDEF";
|
||||||
c = cp[i];
|
c = cp[i];
|
||||||
if (c <= 0x20 ||
|
if (c <= 0x20 ||
|
||||||
c >= 0x7f ||
|
c >= 0x7f ||
|
||||||
c == '"' ||
|
c == '"' ||
|
||||||
c == '#' ||
|
c == '#' ||
|
||||||
c == '%' ||
|
c == '%' ||
|
||||||
c == ';' ||
|
c == ';' ||
|
||||||
c == '<' ||
|
c == '<' ||
|
||||||
c == '>' ||
|
c == '>' ||
|
||||||
c == '?' ||
|
c == '?' ||
|
||||||
c == '[' ||
|
c == '[' ||
|
||||||
c == '\\' ||
|
c == '\\' ||
|
||||||
c == ']' ||
|
c == ']' ||
|
||||||
c == '^' ||
|
c == '^' ||
|
||||||
c == '`' ||
|
c == '`' ||
|
||||||
c == '{' ||
|
c == '{' ||
|
||||||
c == '|' ||
|
c == '|' ||
|
||||||
c == '}') {
|
c == '}') {
|
||||||
out += '%';
|
out += '%';
|
||||||
out += h[(c >> 4) & 0xf];
|
out += h[(c >> 4) & 0xf];
|
||||||
out += h[c & 0xf];
|
out += h[c & 0xf];
|
||||||
@ -794,6 +794,8 @@ static inline int h2d(int c) {
|
|||||||
return c - '0';
|
return c - '0';
|
||||||
else if ('A' <= c && c <= 'F')
|
else if ('A' <= c && c <= 'F')
|
||||||
return 10 + c - 'A';
|
return 10 + c - 'A';
|
||||||
|
else if ('a' <= c && c <= 'f')
|
||||||
|
return 10 + c - 'a';
|
||||||
else
|
else
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -807,7 +809,7 @@ string url_decode(const string &in)
|
|||||||
const char *cp = in.c_str();
|
const char *cp = in.c_str();
|
||||||
string::size_type i = 0;
|
string::size_type i = 0;
|
||||||
for (; i < in.size() - 2; i++) {
|
for (; i < in.size() - 2; i++) {
|
||||||
if (cp[i] == '%') {
|
if (cp[i] == '%') {
|
||||||
int d1 = h2d(cp[i+1]);
|
int d1 = h2d(cp[i+1]);
|
||||||
int d2 = h2d(cp[i+2]);
|
int d2 = h2d(cp[i+2]);
|
||||||
if (d1 != -1 && d2 != -1) {
|
if (d1 != -1 && d2 != -1) {
|
||||||
@ -818,7 +820,7 @@ string url_decode(const string &in)
|
|||||||
out += cp[i+2];
|
out += cp[i+2];
|
||||||
}
|
}
|
||||||
i += 2;
|
i += 2;
|
||||||
} else {
|
} else {
|
||||||
out += cp[i];
|
out += cp[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -861,7 +863,7 @@ string url_parentfolder(const string& url)
|
|||||||
parenturl = url_gpath(url);
|
parenturl = url_gpath(url);
|
||||||
}
|
}
|
||||||
return isfileurl ? string("file://") + parenturl :
|
return isfileurl ? string("file://") + parenturl :
|
||||||
string("http://") + parenturl;
|
string("http://") + parenturl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1112,8 +1114,8 @@ int Pidfile::flopen()
|
|||||||
if (fcntl(m_fd, F_SETLK, &lockdata) != 0) {
|
if (fcntl(m_fd, F_SETLK, &lockdata) != 0) {
|
||||||
int serrno = errno;
|
int serrno = errno;
|
||||||
this->close()
|
this->close()
|
||||||
errno = serrno;
|
errno = serrno;
|
||||||
m_reason = "fcntl lock failed";
|
m_reason = "fcntl lock failed";
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user