@@ -394,125 +394,32 @@ function dtutils_file.check_if_bin_exists(bin)
394394 return result
395395end
396396
397- dtutils_file . libdoc . functions [ " split_filepath " ] = {
398- Name = [[ split_filepath ]] ,
399- Synopsis = [[ split a filepath into parts ]] ,
400- Usage = [[ local df = require "lib/dtutils.file"
397+ -- the following path, filename, etc functions have
398+ -- moved to the string library since they are string
399+ -- manipulation functions, and to prevent circular
400+ -- library inclusiion.
401401
402- local result = df.split_filepath(filepath)
403- filepath - string - path and filename]] ,
404- Description = [[ split_filepath splits a filepath into the path, filename, basename and filetype and puts
405- that in a table]] ,
406- Return_Value = [[ result - table - a table containing the path, filename, basename, and filetype]] ,
407- Limitations = [[ ]] ,
408- Example = [[ ]] ,
409- See_Also = [[ ]] ,
410- Reference = [[ ]] ,
411- License = [[ ]] ,
412- Copyright = [[ ]] ,
413- }
402+ -- these functions are left here for compatibility
403+ -- with older scripts
414404
415405function dtutils_file .split_filepath (str )
416- -- strip out single quotes from quoted pathnames
417- str = string.gsub (str , " '" , " " )
418- str = string.gsub (str , ' "' , ' ' )
419- local result = {}
420- -- Thank you Tobias Jakobs for the awesome regular expression, which I tweaked a little
421- result [" path" ], result [" filename" ], result [" basename" ], result [" filetype" ] = string.match (str , " (.-)(([^\\ /]-)%.?([^%.\\ /]*))$" )
422- if result [" basename" ] == " " and result [" filetype" ]:len () > 1 then
423- result [" basename" ] = result [" filetype" ]
424- result [" filetype" ] = " "
425- end
426- return result
406+ return ds .split_filepath (str )
427407end
428408
429- dtutils_file .libdoc .functions [" get_path" ] = {
430- Name = [[ get_path]] ,
431- Synopsis = [[ get the path from a file path]] ,
432- Usage = [[ local df = require "lib/dtutils.file"
433-
434- local result = df.get_path(filepath)
435- filepath - string - path and filename]] ,
436- Description = [[ get_path strips the filename and filetype from a path and returns the path]] ,
437- Return_Value = [[ result - string - the path]] ,
438- Limitations = [[ ]] ,
439- Example = [[ ]] ,
440- See_Also = [[ ]] ,
441- Reference = [[ ]] ,
442- License = [[ ]] ,
443- Copyright = [[ ]] ,
444- }
445-
446409function dtutils_file .get_path (str )
447- local parts = dtutils_file .split_filepath (str )
448- return parts [" path" ]
410+ return ds .get_path (str )
449411end
450412
451- dtutils_file .libdoc .functions [" get_filename" ] = {
452- Name = [[ get_filename]] ,
453- Synopsis = [[ get the filename and extension from a file path]] ,
454- Usage = [[ local df = require "lib/dtutils.file"
455-
456- local result = df.get_filename(filepath)
457- filepath - string - path and filename]] ,
458- Description = [[ get_filename strips the path from a filepath and returns the filename]] ,
459- Return_Value = [[ result - string - the file name and type]] ,
460- Limitations = [[ ]] ,
461- Example = [[ ]] ,
462- See_Also = [[ ]] ,
463- Reference = [[ ]] ,
464- License = [[ ]] ,
465- Copyright = [[ ]] ,
466- }
467-
468413function dtutils_file .get_filename (str )
469- local parts = dtutils_file .split_filepath (str )
470- return parts [" filename" ]
414+ return ds .get_filename (str )
471415end
472416
473- dtutils_file .libdoc .functions [" get_basename" ] = {
474- Name = [[ get_basename]] ,
475- Synopsis = [[ get the filename without the path or extension]] ,
476- Usage = [[ local df = require "lib/dtutils.file"
477-
478- local result = df.get_basename(filepath)
479- filepath - string - path and filename]] ,
480- Description = [[ get_basename returns the name of the file without the path or filetype
481- ]] ,
482- Return_Value = [[ result - string - the basename of the file]] ,
483- Limitations = [[ ]] ,
484- Example = [[ ]] ,
485- See_Also = [[ ]] ,
486- Reference = [[ ]] ,
487- License = [[ ]] ,
488- Copyright = [[ ]] ,
489- }
490-
491417function dtutils_file .get_basename (str )
492- local parts = dtutils_file .split_filepath (str )
493- return parts [" basename" ]
418+ return ds .get_basename (str )
494419end
495420
496- dtutils_file .libdoc .functions [" get_filetype" ] = {
497- Name = [[ get_filetype]] ,
498- Synopsis = [[ get the filetype from a filename]] ,
499- Usage = [[ local df = require "lib/dtutils.file"
500-
501- local result = df.get_filetype(filepath)
502- filepath - string - path and filename]] ,
503- Description = [[ get_filetype returns the filetype from the supplied filepath]] ,
504- Return_Value = [[ result - string - the filetype]] ,
505- Limitations = [[ ]] ,
506- Example = [[ ]] ,
507- See_Also = [[ ]] ,
508- Reference = [[ ]] ,
509- License = [[ ]] ,
510- Copyright = [[ ]] ,
511- }
512-
513421function dtutils_file .get_filetype (str )
514- local parts = dtutils_file .split_filepath (str )
515- return parts [" filetype" ]
422+ return ds .get_filetype (str )
516423end
517424
518425
0 commit comments