Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
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
videolan
vlc
Commits
51107894
Commit
51107894
authored
Jul 11, 2011
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
vlc_getcwd: return current directory as
UTF-8
parent
2bb92db6
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
60 additions
and
0 deletions
+60
-0
include/vlc_fs.h
include/vlc_fs.h
+1
-0
src/libvlccore.sym
src/libvlccore.sym
+1
-0
src/posix/filesystem.c
src/posix/filesystem.c
+47
-0
src/win32/filesystem.c
src/win32/filesystem.c
+11
-0
No files found.
include/vlc_fs.h
View file @
51107894
...
...
@@ -43,6 +43,7 @@ VLC_API int vlc_mkdir( const char *filename, mode_t mode );
VLC_API
int
vlc_unlink
(
const
char
*
filename
);
VLC_API
int
vlc_rename
(
const
char
*
oldpath
,
const
char
*
newpath
);
VLC_API
char
*
vlc_getcwd
(
void
)
VLC_USED
;
#if defined( WIN32 )
# ifndef UNDER_CE
...
...
src/libvlccore.sym
View file @
51107894
...
...
@@ -467,6 +467,7 @@ vlc_stat
vlc_strcasestr
vlc_unlink
vlc_rename
vlc_getcwd
vlc_dup
vlc_pipe
vlc_accept
...
...
src/posix/filesystem.c
View file @
51107894
...
...
@@ -306,6 +306,53 @@ error:
return
ret
;
}
/**
* Determines the current working directory.
*
* @return the current working directory (must be free()'d)
* or NULL on error
*/
char
*
vlc_getcwd
(
void
)
{
/* Try $PWD */
const
char
*
pwd
=
getenv
(
"PWD"
);
if
(
pwd
!=
NULL
)
{
struct
stat
s1
,
s2
;
/* Make sure $PWD is correct */
if
(
stat
(
pwd
,
&
s1
)
==
0
&&
stat
(
"."
,
&
s2
)
==
0
&&
s1
.
st_dev
==
s2
.
st_dev
&&
s1
.
st_ino
==
s2
.
st_ino
)
return
ToLocaleDup
(
pwd
);
}
/* Otherwise iterate getcwd() until the buffer is big enough */
long
path_max
=
pathconf
(
"."
,
_PC_PATH_MAX
);
size_t
size
=
(
path_max
==
-
1
||
path_max
>
4096
)
?
4096
:
path_max
;
for
(;;
size
*=
2
)
{
char
*
buf
=
malloc
(
size
);
if
(
unlikely
(
buf
==
NULL
))
break
;
if
(
getcwd
(
buf
,
size
)
!=
NULL
)
#ifdef ASSUME_UTF8
return
buf
;
#else
{
char
*
ret
=
ToLocaleDup
(
buf
);
free
(
buf
);
return
ret
;
/* success */
}
#endif
free
(
buf
);
if
(
errno
!=
ERANGE
)
break
;
}
return
NULL
;
}
/**
* Duplicates a file descriptor. The new file descriptor has the close-on-exec
* descriptor flag set.
...
...
src/win32/filesystem.c
View file @
51107894
...
...
@@ -108,6 +108,17 @@ int vlc_mkdir( const char *dirname, mode_t mode )
#endif
}
char
*
vlc_getcwd
(
void
)
{
wchar_t
*
wdir
=
_wgetcwd
(
NULL
,
0
);
if
(
wdir
==
NULL
)
return
NULL
;
char
*
dir
=
FromWide
(
wdir
);
free
(
wdir
);
return
dir
;
}
/* Under Windows, these wrappers return the list of drive letters
* when called with an empty argument or just '\'. */
typedef
struct
vlc_DIR
...
...
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