📄 fn_04.cc
字号:
// file: $isip/class/shell/Filename/fn_04.cc// version: $Id: fn_04.cc,v 1.6 2003/05/05 20:59:32 parihar Exp $//// isip include files//#include "Filename.h"#include <String.h>// method: getBase//// arguments:// String& base: (output) the basename component of the filename//// return: a boolean value indicating status//boolean Filename::getBase(String& base_a) const { if (os_d == UNIX) { return getBaseUnix(base_a); } else { return Error::handle(name(), L"getBase", Error::ARG, __FILE__, __LINE__); }}// method: getExt//// arguments:// String& ext: (output) the extension component of the filename//// return: a boolean value indicating status//boolean Filename::getExt(String& ext_a) const { if (os_d == UNIX) { return getExtUnix(ext_a); } else { return Error::handle(name(), L"getExt", Error::ARG, __FILE__, __LINE__); }}// method: getDir//// arguments:// String& dir: (output) the directory component of the filename//// return: a boolean value indicating status//boolean Filename::getDir(String& dir_a) const { if (os_d == UNIX) { return getDirUnix(dir_a); } else { return Error::handle(name(), L"getDir", Error::ARG, __FILE__, __LINE__); }}// method: getSuffix//// arguments:// String& suffix: (output) the suffix component of the filename//// return: a boolean value indicating status//boolean Filename::getSuffix(String& suffix_a) const { if (os_d == UNIX) { String tmp; getName(tmp); // length of the string value_d // long total_length = tmp.length(); // position of the string slash // long index = tmp.lastStr(UNDERSCORE); if (index == 0) { // no underscore exist, return empty string // suffix_a.assign(L""); } else { // return the substring of value_d // substr(suffix_a, (index + 1), (total_length - index - 1)); } return true; } else { return Error::handle(name(), L"getDir", Error::ARG, __FILE__, __LINE__); }}// method: getName//// arguments:// String& filename: (output) the filename (stripped of the directory)//// return: a boolean value indicating status//boolean Filename::getName(String& filename_a) const { if (os_d == UNIX) { return getNameUnix(filename_a); } else { return Error::handle(name(), L"getName", Error::ARG, __FILE__, __LINE__); }}// method: getDirDelim//// arguments:// String& arg: (output) the string used to delimit a directory//// return: a boolean value indicating status//boolean Filename::getDirDelim(String& arg_a) const { if (os_d == UNIX) { return getDirDelimUnix(arg_a); } else { return Error::handle(name(), L"getDirDelim", Error::ARG, __FILE__, __LINE__); }}// method: getFileDelim//// arguments:// String& arg: (output) the string used to delimit a file extension//// return: a boolean value indicating status//boolean Filename::getFileDelim(String& arg_a) const { if (os_d == UNIX) { return getFileDelimUnix(arg_a); } else { return Error::handle(name(), L"getFileDelim", Error::ARG, __FILE__, __LINE__); }}//-----------------------------------------------------------------------------//// operating system specific versions: UNIX////-----------------------------------------------------------------------------// method: getBaseUnix//// arguments:// String& base: (output) the basename component of the filename//// return: a boolean value indicating status//// this method is essentially equivalent to basename(). a filename// of the form "/home/picone/rje/foo.text" will return "foo".//boolean Filename::getBaseUnix(String& base_a) const { // position from where we have to start trimming // long start = lastStr(SLASH); // position where we stop trimming // long end = lastStr(DOT); // return the substring of value_d // substr(base_a, (start + 1), (end - start - 1)); // exit gracefully // // exit gracefully // return true; }// method: getExtUnix//// arguments:// String& ext: (output) the extension component of the filename//// return: a boolean value indicating status//// find the extension in the filename.//// this method returns the filename's extension. on Unix, this means// for "/home/picone/rje/foo.text" we return "text".//boolean Filename::getExtUnix(String& ext_a) const { // total length of the string // long total_length = length(); // position of the string dot // long index = lastStr(DOT); // return the substring of value_d // substr(ext_a, (index + 1), (total_length - index - 1)); // exit gracefully // return true; }// method: getDirUnix//// arguments:// String& dir: (output) the directory component of the filename//// return: a boolean value indicating status//// this method returns the directory. on Unix, this means// for "/home/picone/rje/foo.text" we return "/home/picone/rje".//boolean Filename::getDirUnix(String& dir_a) const { // position of the string // long index = lastStr(SLASH); // if index is negative then the directory is the current directory // if (index < 0 ) { dir_a.clear(); } // else find the corresponding directory // else { substr(dir_a, 0, index); } // exit gracefully // return true; }// method: getNameUnix//// arguments:// String& filename: (output) the filename (stripped of the directory)//// return: a boolean value indicating status//// this method returns the basename plus extension.// for "/home/picone/rje/foo.text" we return "foo.text".//boolean Filename::getNameUnix(String& filename_a) const { // length of the string value_d // long total_length = length(); // position of the string slash // long index = lastStr(SLASH); // return the substring of value_d // substr(filename_a, (index + 1), (total_length - index - 1)); return true;}// method: getDirDelimUnix//// arguments:// String& arg: (output) the string used to delimit a directory//// return: a boolean value indicating status//// in Unix, this is a SLASH ("/").//boolean Filename::getDirDelimUnix(String& arg_a) const { return arg_a.assign(SLASH);}// method: getFileDelimUnix//// arguments:// String& arg: (output) the string used to delimit a file extension//// return: a boolean value indicating status//// in Unix, this is a DOT (".").//boolean Filename::getFileDelimUnix(String& arg_a) const { return arg_a.assign(DOT);}//-----------------------------------------------------------------------------//// operating system specific versions: WINDOWS////-----------------------------------------------------------------------------// method: getBaseWin//// arguments:// String& base: (output) the basename component of the filename//// return: a boolean value indicating status//boolean Filename::getBaseWin(String& base_a) const { return false;}// method: getExtWin//// arguments:// String& ext: (output) the extension component of the filename//// return: a boolean value indicating status//boolean Filename::getExtWin(String& ext_a) const { return false;}// method: getDirWin//// arguments:// String& dir: (output) the directory component of the filename//// return: a boolean value indicating status//boolean Filename::getDirWin(String& dir_a) const { return false;}// method: getNameWin//// arguments:// String& filename: (output) the filename (stripped of the directory)//// return: a boolean value indicating status//boolean Filename::getNameWin(String& filename_a) const { return false;}// method: getDirDelimWin//// arguments:// String& arg: (output) the string used to delimit a directory//// return: a boolean value indicating status//boolean Filename::getDirDelimWin(String& arg_a) const { return false;}// method: getFileDelimWin//// arguments:// String& arg: (output) the string used to delimit an extension//// return: a boolean value indicating status//boolean Filename::getFileDelimWin(String& arg_a) const { return false;}//-----------------------------------------------------------------------------//// operating system specific versions: MACINTOSH////-----------------------------------------------------------------------------// method: getBaseMac//// arguments:// String& base: (output) the basename component of the filename//// return: a boolean value indicating status//boolean Filename::getBaseMac(String& base_a) const { return false;}// method: getExtMac//// arguments:// String& ext: (output) the extension component of the filename//// return: a boolean value indicating status//boolean Filename::getExtMac(String& ext_a) const { return false;}// method: getDirMac//// arguments:// String& dir: (output) the directory component of the filename//// return: a boolean value indicating status//boolean Filename::getDirMac(String& dir_a) const { return false;}// method: getNameMac//// arguments:// String& filename: (output) the filename (stripped of the directory)//// return: a boolean value indicating status//boolean Filename::getNameMac(String& filename_a) const { return false;}// method: getDirDelimMac//// arguments:// String& arg: (output) the string used to delimit a directory//// return: a boolean value indicating status//boolean Filename::getDirDelimMac(String& arg_a) const { return false;}// method: getFileDelimMac//// arguments:// String& arg: (output) the string used to delimit a file extension//// return: a boolean value indicating status//boolean Filename::getFileDelimMac(String& arg_a) const { return false;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -