c++ - How to go from absolute path to relative path? -
I am making a small program to help in reading the file.
I have to take command from a command line in:
for (i = 1; argc> i; i ++) {QString path = QDir:: Current Path () + "/" + Caststring (argv [i]); QDir dir (path); FileSearch (dir); } From there, I say another method where I look at each file / folder and get the size and its file or folder.
Zero file search (QDir dir) {foreach (QFileInfo info, dir.entryInfoList (QDir :: NoDotAndDotDot | QDir :: Files | QDir :: AllDirs)) {if (info.isFile )) {QDebug () & lt; & Lt; Info.path () & lt; & Lt; "There is a file! Its size is:" & lt; & Lt; Info.size () & lt; & Lt; Endl; } If (info.isDir ()) {qDebug () & lt; & Lt; Info.path () & lt; & Lt; "There is a directory! Its size is:" & lt; & Lt; Info.size () & lt; & Lt; Endl; FileSearch (info.filePath ()); }} Rather than reading the entire path, I want to read only the relative path. So instead of reading it:
Home / John / Desktop / Project / Current Project / Check Directory is a directory! Its size is: 4096 Home / John / Desktop / Project / Current Project / Check Directory / test.txt is a file! Its size is: 4 I have to read this:
is a check directory / a directory! Its size is: 4096 checkdirectory / test.txt is a file! Its size is: 4 postprop Amp;; file name); The relative file path should be returned.
Comments
Post a Comment