Monday, April 22, 2019

programming - How do you describe only the name of the directory in computer science?



In computer science, I found the word "directory name" seems to describe path of the directory. (because when you use dirname command in linux you get path)



Then what word(s) do you use to describe only the name of the directory?



For example, if there is directories as follow,



"C:\folder1\filename.xml"




"folder1" is what I want to describe, not "C:\folder1"


Answer



There are two complimentary commands for parsing a pathname:



Path             Dirname       Basename
one/two/three one/two three
/a/b/c /a/b c
./x/y/ ./x y



The dirname and basename commands were given their names early in UNIX history, so don't rely on their having any consistent naming convention.



Assuming that three and c are files and not directories, generally, one would say:




  • File paths: ./one/two/three, /a/b/c

  • File names: three and c

  • Directory names: two, b, and x

  • Directory paths: one/two, /a/b, and .




The Directory names and paths could also be given a trailing / to make it more obvious that they aren't files.



So in your non-UNIX (C:\folder1\filename.xml) example, filename.xml would be the filename and folder1 would be the directory name.



E.g. "filename.xml is a file in the folder1 directory."


No comments:

Post a Comment