Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
TASTE
uPython-mirror
Commits
1549f170
Commit
1549f170
authored
May 03, 2014
by
Damien George
Browse files
Merge branch 'master' of github.com:micropython/micropython
parents
977a0ce2
fb9ca7c3
Changes
5
Hide whitespace changes
Inline
Side-by-side
unix/main.c
View file @
1549f170
...
...
@@ -394,11 +394,7 @@ int main(int argc, char **argv) {
return
usage
(
argv
);
}
}
else
{
#ifdef __MINGW32__
char
*
basedir
=
_fullpath
(
NULL
,
argv
[
a
],
_MAX_PATH
);
#else
char
*
basedir
=
realpath
(
argv
[
a
],
NULL
);
#endif
if
(
basedir
==
NULL
)
{
fprintf
(
stderr
,
"%s: can't open file '%s': [Errno %d] "
,
argv
[
0
],
argv
[
1
],
errno
);
perror
(
""
);
...
...
windows/Makefile
View file @
1549f170
...
...
@@ -30,6 +30,7 @@ endif
SRC_C
=
\
unix/main.c
\
unix/file.c
\
realpath.c
\
OBJ
=
$(PY_O)
$(
addprefix
$(BUILD)
/,
$(SRC_C:.c=.o)
)
...
...
windows/mpconfigport.h
View file @
1549f170
...
...
@@ -36,3 +36,5 @@ typedef const void *machine_const_ptr_t; // must be of pointer size
extern
const
struct
_mp_obj_fun_native_t
mp_builtin_open_obj
;
#define MICROPY_EXTRA_BUILTINS \
{ MP_OBJ_NEW_QSTR(MP_QSTR_open), (mp_obj_t)&mp_builtin_open_obj },
#include
"realpath.h"
windows/realpath.c
0 → 100644
View file @
1549f170
#include
<stdlib.h>
#include
<errno.h>
#include
<io.h>
#ifndef R_OK
#define R_OK 4
#endif
// Make sure a path only has forward slashes.
char
*
to_unix_path
(
char
*
p
)
{
if
(
p
!=
NULL
)
{
char
*
pp
=
p
;
while
(
*
pp
!=
0
)
{
if
(
*
pp
==
'\\'
)
*
pp
=
'/'
;
++
pp
;
}
}
return
p
;
}
// Implement realpath() using _fullpath and make it use the same error codes as realpath() on unix.
// Also have it return a path with forward slashes only as some code relies on this,
// but _fullpath() returns backward slashes no matter what.
char
*
realpath
(
const
char
*
path
,
char
*
resolved_path
)
{
char
*
ret
=
NULL
;
if
(
path
==
NULL
)
{
errno
=
EINVAL
;
}
else
if
(
access
(
path
,
R_OK
)
==
0
)
{
ret
=
resolved_path
;
if
(
ret
==
NULL
)
ret
=
malloc
(
_MAX_PATH
);
if
(
ret
==
NULL
)
{
errno
=
ENOMEM
;
}
else
{
ret
=
_fullpath
(
ret
,
path
,
_MAX_PATH
);
if
(
ret
==
NULL
)
errno
=
EIO
;
}
}
return
to_unix_path
(
ret
);
}
windows/realpath.h
0 → 100644
View file @
1549f170
extern
char
*
realpath
(
const
char
*
path
,
char
*
resolved_path
);
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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