aboutsummaryrefslogtreecommitdiffstats
path: root/win32
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-03-22 02:26:54 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-03-22 02:26:54 +0000
commit0109f86871d07f65255df6e813a49bc272f5ece8 (patch)
treec492dbb6e049452d8f63d1cba44213202460df1b /win32
parentd26965fcdbf59a290cac61e318e09f11044cff3f (diff)
downloadruby-0109f86871d07f65255df6e813a49bc272f5ece8.tar.gz
win32.c: path_drive
* win32/win32.c (path_drive): extract from winnt_stat, return the drive number in the path, or the current drive. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50052 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'win32')
-rw-r--r--win32/win32.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/win32/win32.c b/win32/win32.c
index d72c3d5316..30b7e27fa0 100644
--- a/win32/win32.c
+++ b/win32/win32.c
@@ -5073,6 +5073,14 @@ stat_by_find(const WCHAR *path, struct stati64 *st)
/* License: Ruby's */
static int
+path_drive(const WCHAR *path)
+{
+ return (iswalpha(path[0]) && path[1] == L':') ?
+ towupper(path[0]) - L'A' : _getdrive() - 1;
+}
+
+/* License: Ruby's */
+static int
winnt_stat(const WCHAR *path, struct stati64 *st)
{
WIN32_FILE_ATTRIBUTE_DATA wfa;
@@ -5103,8 +5111,7 @@ winnt_stat(const WCHAR *path, struct stati64 *st)
if (stat_by_find(path, st)) return -1;
}
- st->st_dev = st->st_rdev = (iswalpha(path[0]) && path[1] == L':') ?
- towupper(path[0]) - L'A' : _getdrive() - 1;
+ st->st_dev = st->st_rdev = path_drive(path);
return 0;
}