Mercurial > projects > ddmd
diff dmd/FileName.d @ 174:af724d3510d7
lot os toCBuffer methods implemented
moved shared Type.* stuff into Global
author | korDen |
---|---|
date | Sun, 10 Oct 2010 03:47:23 +0400 |
parents | 9d194c848e3a |
children | 94b6033c07f3 |
line wrap: on
line diff
--- a/dmd/FileName.d Sun Oct 10 01:55:35 2010 +0400 +++ b/dmd/FileName.d Sun Oct 10 03:47:23 2010 +0400 @@ -156,7 +156,7 @@ break; } } - + return null; } @@ -164,7 +164,7 @@ { return ext(str); } - + /******************************** * Return filename with extension removed. */ @@ -180,7 +180,7 @@ return str; } - + /******************************** * Return filename name excluding path (read-only). */ @@ -222,7 +222,7 @@ { return name(str); } - + /************************************** * Return path portion of str. * Path will does not include trailing path separator. @@ -252,11 +252,11 @@ size_t pathlen = n - str.ptr; return str[0..pathlen]; } - + /************************************** * Replace filename portion of path. */ - + static string replaceName(string path, string name) { if (absolute(name)) @@ -294,7 +294,7 @@ static assert(false); } memcpy(f + pathlen, name.ptr, namelen + 1); - + return assumeUnique(f[0..pathlen+namelen]); } @@ -322,7 +322,7 @@ } else version (Windows) { - if (path[pathlen - 1] != '\\' && + if (path[pathlen - 1] != '\\' && path[pathlen - 1] != '/' && path[pathlen - 1] != ':') { @@ -338,14 +338,14 @@ return assumeUnique(f[0..pathlen+namelen]); } - + static string[] splitPath(const(char)[] spath) { char c = 0; // unnecessary initializer is for VC /W4 scope OutBuffer buf = new OutBuffer(); string[] array; - + if (spath !is null) { const(char)* p = spath.ptr; @@ -358,7 +358,7 @@ p++; --len; } - + buf.reserve(len + 1); // guess size of path for (; len; p++, len--) { @@ -414,10 +414,10 @@ } } while (len > 0); } - + return array; } - + static FileName defaultExt(string name, string ext) { string e = FileName.ext(name); @@ -452,11 +452,11 @@ return defaultExt(name, ext); // doesn't have one } - + /****************************** * Return true if extensions match. */ - + bool equalsExt(string ext) { string e = FileName.ext(); @@ -474,7 +474,7 @@ static assert(0); } } - + /************************************* * Copy file from this to to. */ @@ -494,7 +494,7 @@ file.name = to; file.writev(); } - + /************************************* * Search Path for file. * Input: @@ -506,13 +506,13 @@ if (absolute(name)) { return exists(name) ? name : null; } - + if (cwd) { if (exists(name)) { return name; } } - + if (path !is null) { foreach (i; 0..path.dim) { @@ -523,7 +523,7 @@ return n; } } - + return null; } @@ -532,13 +532,13 @@ if (absolute(name)) { return exists(name) ? name : null; } - + if (cwd) { if (exists(name)) { return name; } } - + if (path !is null) { foreach (i, p; path) { @@ -548,7 +548,7 @@ return n; } } - + return null; } @@ -567,7 +567,7 @@ if (h == INVALID_HANDLE_VALUE) { return 0; } - + CloseHandle(h); DWORD dw = GetFileAttributesA(name.ptr); /// CARE! @@ -583,7 +583,7 @@ static assert(0); } } - + static void ensurePathExists(string path) { if (path.length == 0)