Skip to content

Commit 607da8d

Browse files
committed
in code comments
1 parent 41ac1fd commit 607da8d

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

example/system/example_cwd.f90

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ program example_cwd
2525

2626
if (err%error()) then
2727
print *, "Error getting current working directory after using set_cwd: "//err%print()
28-
return
2928
end if
3029

3130
print *, "CWD: "//path

src/stdlib_system.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ int stdlib_remove_directory(const char* path){
4747
return (!code) ? 0 : errno;
4848
}
4949

50+
// Wrapper to the platform's `getcwd`(get current working directory) call.
51+
// Uses `getcwd` on unix, `_getcwd` on windows.
52+
// Returns the cwd, sets the length of cwd and the `stat` of the operation.
5053
char* stdlib_get_cwd(size_t* len, int* stat){
5154
*stat = 0;
5255
#ifdef _WIN32
@@ -75,6 +78,9 @@ char* stdlib_get_cwd(size_t* len, int* stat){
7578
#endif /* ifdef _WIN32 */
7679
}
7780

81+
// Wrapper to the platform's `chdir`(change directory) call.
82+
// Uses `chdir` on unix, `_chdir` on windows.
83+
// Returns 0 if successful, otherwise returns the `errno`.
7884
int stdlib_set_cwd(char* path) {
7985
int code;
8086
#ifdef _WIN32
@@ -83,6 +89,5 @@ int stdlib_set_cwd(char* path) {
8389
code = chdir(path);
8490
#endif /* ifdef _WIN32 */
8591

86-
if (code == -1) return errno;
87-
return 0;
92+
return (code == -1) ? errno : 0;
8893
}

0 commit comments

Comments
 (0)