我有一个接受目录路径作为字符串的 C 函数。该函数在给定路径创建一个目录。
int create_directory(const char *path) {
// given path may be absolute or relative
// step 1:-need to validate the given path(cross platform for both Linux and windows)
// what are the criteria for path validation?
// step 2:- check permission about user accessibility ,means can not create directory, if path is like /usr/bin or /root).but in root login then we create.
So what are the criteria for validation?
// step 3:-if directory, subdirectory already exist at the path, then return?
// step 4:-if not exists then create directory ;
}
基本上我在第 1 步和第 2 步中遇到问题。我无法确定路径验证的确切标准是什么。