ディレクトリ パスを文字列として受け入れる 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 に問題があります。パス検証の正確な基準を特定できません。