@@ -6251,3 +6251,78 @@ function remove_file() {
6251
6251
_file_cache_remove " $target_file " ;
6252
6252
return 0;
6253
6253
}
6254
+
6255
+ # [API function]
6256
+ # Creates a subdirectory within the project target directory.
6257
+ #
6258
+ # The subdirectory is specified by the first argument. The path is interpreted as
6259
+ # relative to the project target directory. It may contain one or more
6260
+ # subdirectories hierarchically. Any nonexistent parent directories are
6261
+ # also implicitly created.
6262
+ #
6263
+ # When in regular (form-based) application mode, the project target directory must have
6264
+ # already been created by means of the project_init_copy() function before a directory
6265
+ # can be created.
6266
+ #
6267
+ # If the specified subdirectory structure already exists, then this function
6268
+ # has no effect.
6269
+ #
6270
+ # When in Quickstart mode, the project target directory is the underlying Quickstart
6271
+ # current working directory, i.e. where the Quickstart was initiated.
6272
+ #
6273
+ # Since:
6274
+ # 1.9.0
6275
+ #
6276
+ # Args:
6277
+ # $1 - The relative path of the subdirectory to create in the project target directory.
6278
+ # The path must not be absolute. This is a mandatory argument.
6279
+ #
6280
+ # Returns:
6281
+ # 0 - If the create operation was successful.
6282
+ # 1 - If the create operation has failed.
6283
+ #
6284
+ # Examples:
6285
+ # create_directory "data";
6286
+ # create_directory "src/main/my_new_dir";
6287
+ #
6288
+ function create_directory() {
6289
+ local arg_dir_path=" $1 " ;
6290
+ _require_arg " $arg_dir_path " " No path argument specified" ;
6291
+ if _is_absolute_path " $arg_dir_path " ; then
6292
+ _fail_illegal_call " The path argument must not be absolute" ;
6293
+ fi
6294
+ local file_path=" " ;
6295
+ if [[ $PROJECT_INIT_QUICKSTART_REQUESTED == true ]]; then
6296
+ file_path=" ${_PROJECT_INIT_QUICKSTART_OUTPUT_DIR} /${arg_dir_path} " ;
6297
+ if [ -e " $file_path " ]; then
6298
+ if ! _array_contains " $file_path " " ${CACHE_ALL_FILES[@]} " ; then
6299
+ _make_func_hl " create_directory" ;
6300
+ logW " Cannot create directory at '${arg_dir_path} '" ;
6301
+ logW " A file at that location already exists" ;
6302
+ _cancel_quickstart $EXIT_FAILURE ;
6303
+ fi
6304
+ fi
6305
+ else
6306
+ _ensure_project_files_copied;
6307
+ file_path=" ${var_project_dir} /${arg_dir_path} " ;
6308
+ fi
6309
+ local add_file_to_cache=false;
6310
+ if ! [ -e " $file_path " ]; then
6311
+ add_file_to_cache=true;
6312
+ else
6313
+ if ! [ -d " $file_path " ]; then
6314
+ logW " Cannot create directory at '${arg_dir_path} '" ;
6315
+ logW " A file at that location already exists but is not a directory" ;
6316
+ _cancel_quickstart $EXIT_FAILURE ;
6317
+ return 1;
6318
+ fi
6319
+ fi
6320
+ if ! mkdir -p " $file_path " ; then
6321
+ logE " Failed to create directory or one of its parents: '${arg_dir_path} '" ;
6322
+ return 1;
6323
+ fi
6324
+ if [[ $add_file_to_cache == true ]]; then
6325
+ _file_cache_add " $file_path " ;
6326
+ fi
6327
+ return 0;
6328
+ }
0 commit comments