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
5b30f789
Commit
5b30f789
authored
Dec 14, 2019
by
dearblue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Avoid method in method
And rename `File.concat_path` to `File._concat_path`.
parent
6c5ee8f7
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
33 deletions
+33
-33
mrbgems/mruby-io/mrblib/file.rb
mrbgems/mruby-io/mrblib/file.rb
+33
-33
No files found.
mrbgems/mruby-io/mrblib/file.rb
View file @
5b30f789
...
@@ -55,46 +55,46 @@ class File < IO
...
@@ -55,46 +55,46 @@ class File < IO
s
s
end
end
def
self
.
expand_path
(
path
,
default_dir
=
'.'
)
def
self
.
_concat_path
(
path
,
base_path
)
def
concat_path
(
path
,
base_path
)
if
path
[
0
]
==
"/"
||
path
[
1
]
==
':'
# Windows root!
if
path
[
0
]
==
"/"
||
path
[
1
]
==
':'
# Windows root!
expanded_path
=
path
expanded_path
=
path
elsif
path
[
0
]
==
"~"
elsif
path
[
0
]
==
"~"
if
(
path
[
1
]
==
"/"
||
path
[
1
]
==
nil
)
if
(
path
[
1
]
==
"/"
||
path
[
1
]
==
nil
)
dir
=
path
[
1
,
path
.
size
]
dir
=
path
[
1
,
path
.
size
]
home_dir
=
_gethome
home_dir
=
_gethome
unless
home_dir
unless
home_dir
raise
ArgumentError
,
"couldn't find HOME environment -- expanding '~'"
raise
ArgumentError
,
"couldn't find HOME environment -- expanding '~'"
end
end
expanded_path
=
home_dir
expanded_path
+=
dir
if
dir
expanded_path
+=
"/"
else
splitted_path
=
path
.
split
(
"/"
)
user
=
splitted_path
[
0
][
1
,
splitted_path
[
0
].
size
]
dir
=
"/"
+
splitted_path
[
1
,
splitted_path
.
size
].
join
(
"/"
)
home_dir
=
_gethome
(
user
)
expanded_path
=
home_dir
expanded_path
+=
dir
if
dir
expanded_path
+=
"/"
else
splitted_path
=
path
.
split
(
"/"
)
user
=
splitted_path
[
0
][
1
,
splitted_path
[
0
].
size
]
dir
=
"/"
+
splitted_path
[
1
,
splitted_path
.
size
].
join
(
"/"
)
unless
home_dir
home_dir
=
_gethome
(
user
)
raise
ArgumentError
,
"user
#{
user
}
doesn't exist"
end
expanded_path
=
home_dir
unless
home_dir
expanded_path
+=
dir
if
dir
raise
ArgumentError
,
"user
#{
user
}
doesn't exist"
expanded_path
+=
"/"
end
end
else
expanded_path
=
concat_path
(
base_path
,
_getwd
)
expanded_path
+=
"/"
+
path
end
expanded_path
expanded_path
=
home_dir
expanded_path
+=
dir
if
dir
expanded_path
+=
"/"
end
else
expanded_path
=
_concat_path
(
base_path
,
_getwd
)
expanded_path
+=
"/"
+
path
end
end
expanded_path
=
concat_path
(
path
,
default_dir
)
expanded_path
end
def
self
.
expand_path
(
path
,
default_dir
=
'.'
)
expanded_path
=
_concat_path
(
path
,
default_dir
)
drive_prefix
=
""
drive_prefix
=
""
if
File
::
ALT_SEPARATOR
&&
expanded_path
.
size
>
2
&&
if
File
::
ALT_SEPARATOR
&&
expanded_path
.
size
>
2
&&
(
"A"
..
"Z"
).
include?
(
expanded_path
[
0
].
upcase
)
&&
expanded_path
[
1
]
==
":"
(
"A"
..
"Z"
).
include?
(
expanded_path
[
0
].
upcase
)
&&
expanded_path
[
1
]
==
":"
...
...
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