File and Folder Operations in C++
<p>I am writing a todo list manager program in C++ and would like to do the following:</p>



<ol>
<li>Check if a directory exists in the program's working directory, if not create it</li>
<li>If it does exist, get a list of .txt files from it.</li>
<li>Be able to create/delete .txt files from this directory</li>
</ol>

<p>I have tried using <code>boost/filesystem.hpp</code> but can't seem to figure it out (or how to get it to link using g++). Below is an example of what I have tried (assume proper <code>#includes</code>'s, <code>int main</code>, etc):</p>

<pre class="lang-cpp prettyprint-override"><code>std::vector&lt;std::string&gt; findLists(void){
    std::vector&lt;std::string&gt; lists;
    std::string temp;
    char dir[ MAX_PATH ];
    std::string(dir, GetModuleFileName(NULL, dir, MAX_PATH));
    dir = dir.substr(0,dir.find_last_of( "\\/" ));
    path p(dir);
    for(auto i = directory_iterator(p); i != directory_iterator(); i++){
        if(!is_directory(i-&gt;path())){
            temp = i-&gt;path().filename().string();
            if(temp.compare(0,temp.find(".")+1,".txt")){
                temp = temp.substr(0,temp.find("."));
            }
            lists.push_back(temp);
        }
        else{
            continue;
        }
    }

    return lists;
}
</code></pre>