mirror of
https://github.com/RubyMetric/chsrc
synced 2025-06-09 04:16:21 +08:00
Add xy_parent_dir()
This commit is contained in:
parent
7968310c93
commit
afe6f96611
@ -3,7 +3,7 @@
|
|||||||
* License : MIT
|
* License : MIT
|
||||||
* Authors : Aoran Zeng <ccmywish@qq.com>
|
* Authors : Aoran Zeng <ccmywish@qq.com>
|
||||||
* Created on : <2023-08-30>
|
* Created on : <2023-08-30>
|
||||||
* Last modified : <2023-09-27>
|
* Last modified : <2023-09-29>
|
||||||
*
|
*
|
||||||
* test_xy:
|
* test_xy:
|
||||||
*
|
*
|
||||||
@ -92,6 +92,7 @@ main (int argc, char const *argv[])
|
|||||||
assert(false==xy_file_exist(xy_win_powershellv5_profile));
|
assert(false==xy_file_exist(xy_win_powershellv5_profile));
|
||||||
|
|
||||||
puts (xy_uniform_path(" \n ~/haha/test/123 \n\r "));
|
puts (xy_uniform_path(" \n ~/haha/test/123 \n\r "));
|
||||||
|
assert_str (xy_uniform_path("~/haha/test"), xy_parent_dir (" ~/haha/test/123") );
|
||||||
|
|
||||||
xy_success("测试全部通过");
|
xy_success("测试全部通过");
|
||||||
return 0;
|
return 0;
|
||||||
|
18
xy.h
18
xy.h
@ -3,7 +3,7 @@
|
|||||||
* License : MIT
|
* License : MIT
|
||||||
* Authors : Aoran Zeng <ccmywish@qq.com>
|
* Authors : Aoran Zeng <ccmywish@qq.com>
|
||||||
* Created on : <2023-08-28>
|
* Created on : <2023-08-28>
|
||||||
* Last modified : <2023-09-27>
|
* Last modified : <2023-09-29>
|
||||||
*
|
*
|
||||||
* xy:
|
* xy:
|
||||||
*
|
*
|
||||||
@ -557,4 +557,20 @@ xy_uniform_path (const char* path)
|
|||||||
return new;
|
return new;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static char*
|
||||||
|
xy_parent_dir (const char* path)
|
||||||
|
{
|
||||||
|
char* dir = xy_uniform_path (path);
|
||||||
|
char* last = NULL;
|
||||||
|
if (xy_on_windows) {
|
||||||
|
last = strrchr(dir, '\\');
|
||||||
|
*last = '\0';
|
||||||
|
} else {
|
||||||
|
last = strrchr(dir, '/');
|
||||||
|
*last = '\0';
|
||||||
|
}
|
||||||
|
return dir;
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user