Path Manipulator c++

Often file specifications need to be manipulated to generate the desired results for CodeBlocks projects.  Our exercise begins with the following structure.

[codesyntax lang=”cpp”]

struct rPath_area
    string rawPath = "/home/archman/workspace/cb/cpp/pathManip/pathManip.cbp";
    int eop; // Value used for scannind
    string pathOnly; // Just the file path
    string fileNameOnly; // File name and extension
    string xqt; // Executable file name
    string xqtFs; // Command line to run the release version of the project
    string compileCl; // Command line for compling the project in CodeBlocks


rPath_area pm;


Notice the rawPath variable contains the CodeBlocks project file specification in question.

The following method populates the remaining fields.

[codesyntax lang=”cpp”]

void pathManipFrame::OnmenManipFsSelected(wxCommandEvent& event)
    pm.eop = pm.rawPath.find_last_of("/");
    pm.pathOnly = pm.rawPath.substr(0, pm.eop);
    pm.fileNameOnly = pm.rawPath.substr(pm.eop+1);
    pm.xqt = pm.fileNameOnly.substr(0, pm.fileNameOnly.find_last_of("."));
    pm.xqtFs = pm.pathOnly + "/bin/Release/" + pm.xqt;
    pm.compileCl = "/usr/bin/codeblocks ";
    pm.compileCl = pm.compileCl + pm.rawPath;
    pm = pm;



The output of the code execution is depicted below in the debugger watch window.

When working with CodeBlocks projects populate the rawPath with the project file specification then invoke the method to poulate the remaing fields.

The user may utilize as many of the fields necessary to complete the subject objective.

Mr. Arch Brooks, Software Engineer, Brooks Computing Systems, LLC authored this article.

Leave a Reply

Your email address will not be published. Required fields are marked *