Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mruby
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
mruby
Commits
ab1465d9
Commit
ab1465d9
authored
Mar 08, 2020
by
Reckordp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Traditional, UNC, and Device Is Absolute?
parent
66c44b85
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
14 deletions
+18
-14
mrbgems/mruby-io/src/file.c
mrbgems/mruby-io/src/file.c
+18
-14
No files found.
mrbgems/mruby-io/src/file.c
View file @
ab1465d9
...
@@ -281,52 +281,56 @@ mrb_file__getwd(mrb_state *mrb, mrb_value klass)
...
@@ -281,52 +281,56 @@ mrb_file__getwd(mrb_state *mrb, mrb_value klass)
}
}
#ifdef _WIN32
#ifdef _WIN32
#define IS_FILESEP(x) (x ==
FILE_SEPARATOR || x == FILE_ALT_SEPARATOR
)
#define IS_FILESEP(x) (x ==
(*(char*)(FILE_SEPARATOR)) || x == (*(char*)(FILE_ALT_SEPARATOR))
)
#define IS_VOLSEP(x) (x ==
VOLUME_SEPARATOR
)
#define IS_VOLSEP(x) (x ==
(*(char*)(VOLUME_SEPARATOR))
)
#define IS_DEVICEID(x) (x == '.' || x == '?')
#define IS_DEVICEID(x) (x == '.' || x == '?')
#define CHECK_UNCDEV_PATH (IS_FILESEP(path[0]) && IS_FILESEP(path[1]))
static
int
static
int
is_absolute_traditional_path
(
const
char
*
path
,
int
len
)
is_absolute_traditional_path
(
const
char
*
path
,
int
len
)
{
{
if
(
len
<
3
)
return
0
;
if
(
len
<
3
)
return
0
;
if
(
IS_FILESEP
(
path
[
0
]))
return
1
;
return
(
ISALPHA
(
path
[
0
])
&&
IS_VOLSEP
(
path
[
1
])
&&
IS_FILESEP
(
path
[
2
]));
return
(
ISALPHA
(
path
[
0
])
&&
IS_VOLSEP
(
path
[
1
])
&&
IS_FILESEP
(
path
[
2
]));
}
}
static
int
static
int
is_aboslute_unc_path
(
const
char
*
path
,
int
len
)
{
is_aboslute_unc_path
(
const
char
*
path
,
int
len
)
{
if
(
len
<
2
)
return
0
;
if
(
len
<
2
)
return
0
;
return
(
IS_FILESEP
(
path
[
0
])
&&
IS_FILESEP
(
path
[
1
]));
return
(
CHECK_UNCDEV_PATH
&&
!
IS_DEVICEID
(
path
[
2
]));
}
}
static
int
static
int
is_absolute_device_path
(
const
char
*
path
,
int
len
)
{
is_absolute_device_path
(
const
char
*
path
,
int
len
)
{
if
(
len
<
4
)
return
0
;
if
(
len
<
4
)
return
0
;
return
(
is_aboslute_unc_path
(
path
,
len
)
&&
IS_DEVICEID
(
path
[
2
])
&&
IS_FILESEP
(
path
[
3
]));
return
(
CHECK_UNCDEV_PATH
&&
IS_DEVICEID
(
path
[
2
])
&&
IS_FILESEP
(
path
[
3
]));
}
}
static
int
static
int
mrb_file_is_absolute_path
(
const
char
*
path
,
int
len
)
mrb_file_is_absolute_path
(
const
char
*
path
,
int
len
)
{
{
return
(
if
(
IS_FILESEP
(
path
[
0
]))
return
1
;
is_absolute_traditional_path
(
path
,
len
)
||
if
(
len
>
0
)
is_aboslute_unc_path
(
path
,
len
)
||
return
(
is_absolute_device_path
(
path
,
len
)
is_absolute_traditional_path
(
path
,
len
)
||
);
is_aboslute_unc_path
(
path
,
len
)
||
is_absolute_device_path
(
path
,
len
)
);
else
return
0
;
}
#undef IS_FILESEP
#undef IS_FILESEP
#undef IS_VOLSEP
#undef IS_VOLSEP
#undef IS_DEVICEID
#undef IS_DEVICEID
#undef CHECK_UNCDEV_PATH
#else
#else
static
int
static
int
mrb_file_is_absolute_path
(
const
char
*
path
)
mrb_file_is_absolute_path
(
const
char
*
path
)
{
{
#define IS_FILESEP(x) (x == FILE_SEPARATOR)
return
(
path
[
0
]
==
*
(
char
*
)(
FILE_SEPARATOR
));
return
IS_FILESEP
(
path
[
0
]);
#undef IS_FILESEP
#endif
}
}
#endif
static
mrb_value
static
mrb_value
mrb_file__gethome
(
mrb_state
*
mrb
,
mrb_value
klass
)
mrb_file__gethome
(
mrb_state
*
mrb
,
mrb_value
klass
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment