(Ruby) Demonstrate Directory Path Functions
Demonstrates the path functions GetDirectoryName, GetExtension, GetFileName, and GetFileNameWithoutExtension.
require 'chilkat'
fac = Chilkat::CkFileAccess.new()
# Note: Chilkat accepts either forward slash or backslash chars as directory separators..
print fac.getDirectoryName("/MyDir/MySubDir/myfile.ext") + "\n";
print fac.getDirectoryName("/MyDir/MySubDir") + "\n";
print fac.getDirectoryName("/MyDir/") + "\n";
print fac.getDirectoryName("/MyDir") + "\n";
print fac.getDirectoryName("/") + "\n";
print fac.getExtension("C:/mydir.old/myfile.ext") + "\n";
print fac.getExtension("C:/mydir.old/") + "\n";
print fac.getFileName("C:/mydir/myfile.ext") + "\n";
print fac.getFileName("C:/mydir/") + "\n";
print fac.getFileNameWithoutExtension("C:/mydir/myfile.ext") + "\n";
print fac.getFileNameWithoutExtension("C:/mydir/") + "\n";
print "---" + "\n";
|