<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Dateien von HDD auflisten und als Linkliste speichern]]></title><description><![CDATA[<p>Ich suche ein Tool womit ich alle Dateien eines Ordners (mit den Dateien aus Unterordnern) auflisten kann und die Links zu den Dateien in eine .txt Datei abspeichern kann.<br />
z.B.<br />
Ordner\Datei1<br />
Ordner\Ordner1\Datei2</p>
<p>Habe schon sowas ähnliches gefunden, nur das keine Links zu den Dateien gespeichert werden. Vielleicht hat ja jemand so ein Programm oder kann mir beim anpassen des Quelltextes helfen.<br />
Ich kann nur ein wenig C und verstehe deshalb die meisten Funktionen nicht.</p>
<pre><code class="language-cpp">/*
 * This file is part of DirectoryNavigator.
 * Copyright (C) 2005 - 2009 CodePlanet. All rights reserved.
 *
 * DirectoryNavigator is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * DirectoryNavigator is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with DirectoryNavigator.  If not, see &lt;http://www.gnu.org/licenses/&gt;. 
 */

#include &quot;listdir.h&quot;
#include &quot;timer.h&quot;

/**
 * File:          listdir.cpp                                          
 * Description:   Recursively walk through directories, starting        
 *                at a specified path and insert it into a an          
 *                STL-like container class for n-ary trees.           
 * Version:       1.0                                                 
 * Language:      C++, MSVC 8.0                                        
 * Platform:      x86, Windows NT                                      
 * Author:        http://www.codeplanet.eu/              
 */
Item::Item()
{ 
}

Item::~Item()
{
}

// Default dir name display function
void Item::dirsItem(const std::string&amp; dirName) 
{ 
    std::cout &lt;&lt; &quot;\n  &quot; &lt;&lt; dirName  &lt;&lt; std::endl;
}

// Default file data display function
void Item::fileItem(const WIN32_FIND_DATA *findData) 
{
    int filesize = findData-&gt;nFileSizeLow;

    FILETIME ft;
    FileTimeToLocalFileTime(&amp;(findData-&gt;ftLastWriteTime), &amp;ft);
    SYSTEMTIME st;
    FileTimeToSystemTime(&amp;ft, &amp;st);

    std::cout &lt;&lt; &quot;\t&quot;;
    std::cout.setf(std::ios::left, std::ios::adjustfield);
    std::cout &lt;&lt; std::setw(15) &lt;&lt; findData-&gt;cFileName;
    std::cout.setf(std::ios::right, std::ios::adjustfield);
    std::cout &lt;&lt; std::setw(10) &lt;&lt; filesize &lt;&lt; &quot;    &quot;;
    std::cout &lt;&lt; std::setw(2) &lt;&lt; st.wMonth &lt;&lt; &quot;/&quot;
              &lt;&lt; std::setw(2) &lt;&lt; st.wDay &lt;&lt; &quot;/&quot;
              &lt;&lt; std::setw(4) &lt;&lt; st.wYear &lt;&lt; &quot;  &quot;
              &lt;&lt; std::setw(2) &lt;&lt; st.wHour &lt;&lt; &quot;:&quot;
              &lt;&lt; std::setw(2) &lt;&lt; st.wMinute &lt;&lt; std::endl;  
}

// Constructor: Save user's working directory
Navigator::Navigator(std::string r)
: root(r), directories(0), files(0)
{
    // Create first element at the top
    viter.push_back(strTree.begin());                     
    viter.push_back(strTree.insert(viter[0], &quot;&quot;));

    // save user's working directory
    char buffer[256];
    GetCurrentDirectory(256, buffer);
    userDir = buffer;
    p = new Item();
}

// Use alternate Item class
void Navigator::use(Item *dp) 
{ 
    delete p;
    p = dp; 
}

// Destructor: Restore user's working directory
// and delete p
Navigator::~Navigator() 
{  
    SetCurrentDirectory(userDir.c_str()); 
    delete p;
}

// Specify starting directory and initiate walk
void Navigator::start() 
{
    // Convert &quot;.&quot; or &quot;..&quot; into full path name
    char buffer[256];

    if( (root == &quot;.&quot;) || (root == &quot;..&quot;) ) {
        if( !SetCurrentDirectory(root.c_str()) )
            std::cout &lt;&lt; &quot;Could not find directory &quot; &lt;&lt; root &lt;&lt; std::endl;

        GetCurrentDirectory(256, buffer);
        root = buffer;
    }

    // Start recursive directory walk
    walk(root);
}

// Walk directory tree rooted at dir
void Navigator::walk(const std::string &amp;dir) 
{
    char *fileName;
    char curDir[256];
    char fullName[256];
    HANDLE fileHandle;
    WIN32_FIND_DATA findData;
    std::string fileMask = &quot;*.*&quot;;

    // Save current dir so we can restore it
    if( !GetCurrentDirectory(256, curDir) ) 
        return;

    // If the directory name is neither . or .. then
    // change to it, otherwise ignore it                              
    if( (dir != &quot;.&quot;) &amp;&amp; (dir != &quot;..&quot;) ) {
        if(!SetCurrentDirectory(dir.c_str())) 
            return;
    } else {
        return;
    }

    // Print out the current directory name
    if( !GetFullPathName(fileMask.c_str(), 256, fullName, &amp;fileName) ) 
        return;

    std::string tmp(fullName);
    ++directories;

    /* Check if we have more subdirectory's
    if(lastDir.compare(curDir) == 0)      
        std::cout &lt;&lt; &quot;Another Subdirectory!&quot; &lt;&lt; std::endl;
    */
    viter.push_back(strTree.append_child(viter[viter.size()-1], tmp));

    // Loop through all files in the directory
    fileHandle = FindFirstFile(fileMask.c_str(), &amp;findData);

    while( fileHandle != INVALID_HANDLE_VALUE ) {
        // If the name is a directory,
        // recursively walk it. Otherwise print
        // print the file's data
        if( findData.dwFileAttributes &amp; FILE_ATTRIBUTE_DIRECTORY ) {
            // OK, it is a directory
            walk(findData.cFileName);
        } else {
            fileItem(&amp;findData);
        }

        // Loop through remaining entries in the dir
        if( !FindNextFile(fileHandle, &amp;findData) )
            break;
    }

    // Clean up and restore directory
    FindClose(fileHandle);
    SetCurrentDirectory(curDir);
    viter.pop_back();
}

// Write our tree to console
void Navigator::displayTree()
{
    tree&lt;std::string&gt;::pre_order_iterator it = strTree.begin(), end = strTree.end();

    if( !strTree.is_valid(it) ) {
        throw Exception(Exception::INVALID_ARGUMENT, &quot;Navigator: Could not display tree. No valid tree object!&quot;);
        return;
    }

    int rootdepth = strTree.depth(it);
    std::cout &lt;&lt; &quot;---------------------------------------------------&quot; &lt;&lt; std::endl;
    while( it != end ) {
        for(int i=0; i &lt; strTree.depth(it)-rootdepth; ++i) 
            std::cout &lt;&lt; &quot;  &quot;;
        std::cout &lt;&lt; (*it) &lt;&lt; std::endl &lt;&lt; std::flush;
        ++it;
    }
    std::cout &lt;&lt; &quot;---------------------------------------------------&quot; &lt;&lt; std::endl;
}

// Write our tree into a file
void Navigator::writeToFile(std::ofstream&amp; filestream)
{
    tree&lt;std::string&gt;::pre_order_iterator it = strTree.begin(), end = strTree.end();

    if( !strTree.is_valid(it) ) 
        throw Exception(Exception::INVALID_ARGUMENT, &quot;Navigator: Could not write tree to file. No valid tree object!&quot;);

    int rootdepth = strTree.depth(it);
    filestream &lt;&lt; &quot;\nDirectory Tree Structure of &quot; &lt;&lt; root &lt;&lt; &quot;:&quot; &lt;&lt; std::endl; 
    filestream &lt;&lt; &quot;---------------------------------------------------&quot; &lt;&lt; std::endl;
    while( it != end ) {
      for( int i=0; i &lt; strTree.depth(it) - rootdepth; ++i ) 
         filestream &lt;&lt; &quot;  &quot;;
      filestream &lt;&lt; (*it) &lt;&lt; std::endl &lt;&lt; std::flush;
      ++it;
    }
    filestream &lt;&lt; std::endl;    
}

// Insert file data to our tree
void Navigator::fileItem(const WIN32_FIND_DATA *findData)
{
    int filesize = findData-&gt;nFileSizeLow; 

    FILETIME ft;
    FileTimeToLocalFileTime(&amp;(findData-&gt;ftLastWriteTime), &amp;ft);
    SYSTEMTIME st;
    FileTimeToSystemTime(&amp;ft, &amp;st);

    std::string fileData(findData-&gt;cFileName);

    // Need some Conversion ;)
    std::stringstream ss;

    //ss &lt;&lt; std::setw(10) &lt;&lt; filesize &lt;&lt; &quot;    &quot; 
    //   &lt;&lt; std::setw(2) &lt;&lt; std::setfill('0') &lt;&lt; st.wDay &lt;&lt; &quot;/&quot;
    //   &lt;&lt; std::setw(2) &lt;&lt; st.wMonth &lt;&lt; &quot;/&quot;
    //   &lt;&lt; std::setw(4) &lt;&lt; st.wYear &lt;&lt; &quot;  &quot;
    //   &lt;&lt; std::setw(2) &lt;&lt; st.wHour &lt;&lt; &quot;:&quot;
    //   &lt;&lt; std::setw(2) &lt;&lt; st.wMinute; 

    fileData += ss.str();

    strTree.append_child( viter[viter.size()-1], fileData );
    ++files;
}

void Navigator::sortTree()
{
    // Sorting the entire tree, level by level    
    strTree.sort( strTree.begin(), strTree.end(), true ); 
}

void Navigator::setNewRoot(const std::string&amp; nroot)
{ 
    // Clear up data
    strTree.clear();
    viter.clear();

    if( strTree.empty() &amp;&amp; viter.empty() ) {
        root = nroot; 

        // Create first element at the top
        viter.push_back(strTree.begin());                     
        viter.push_back(strTree.insert(viter[0], &quot;&quot;));
    } else {
        throw Exception(Exception::OTHER_ERROR, &quot;Navigator: setNewRoot failed!&quot;);
    }
}
</code></pre>
<pre><code class="language-cpp">/*
 * This file is part of DirectoryNavigator.
 * Copyright (C) 2005 - 2009 CodePlanet. All rights reserved.
 *
 * DirectoryNavigator is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * DirectoryNavigator is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with DirectoryNavigator.  If not, see &lt;http://www.gnu.org/licenses/&gt;. 
 */

#include &quot;listdir.h&quot;
#include &quot;timer.h&quot;

/**
 * File:          main.cpp                                             
 * Description:   This is the main class. It shows some examples how to    
 *                use the other classes like Navigator and Timer. 
 * Version:       1.0                                                  
 * Language:      C++, MSVC 8.0                                        
 * Platform:      x86, Windows NT                                  
 * Author:        http://www.codeplanet.eu/ 
 */
int main(int argc, char *argv[]) 
{
    try {
        if(argc &lt; 2) 
            throw InvalidArgument(&quot;Please enter one starting path!&quot;);

        unsigned long dwResult = GetFileAttributes(argv[1]);

        if(dwResult == INVALID_FILE_ATTRIBUTES)
            throw InvalidArgument(&quot;Please enter a valid path!&quot;);
        else if(!(dwResult &amp; FILE_ATTRIBUTE_DIRECTORY))
            throw InvalidArgument(&quot;This is not a directory!&quot;);

        const char filename[] = &quot;output.txt&quot;;
        SYSTEMTIME st;
        GetSystemTime(&amp;st);  
        std::ofstream file(filename, std::ios_base::out);
        Timer tim;

        tim.StartTimer();   // Start a timer

        if( !file )
            throw Exception(Exception::IO_ERROR, &quot;Error opening file!&quot;);

        file &lt;&lt; &quot;Listing generated at: &quot; &lt;&lt; st.wDay  &lt;&lt; &quot;.&quot; &lt;&lt; st.wMonth&lt;&lt; &quot;.&quot; &lt;&lt; st.wYear 
             &lt;&lt; &quot; - &quot; &lt;&lt; std::setw(2) &lt;&lt; std::setfill('0') &lt;&lt; st.wHour &lt;&lt; &quot;:&quot;
             &lt;&lt; std::setw(2) &lt;&lt; st.wMinute &lt;&lt; &quot;:&quot; &lt;&lt; std::setw(2) 
             &lt;&lt; st.wSecond &lt;&lt; &quot; (GMT)&quot; &lt;&lt; std::setfill(' ') &lt;&lt; std::endl;

        // Create new instance
        Navigator o(argv[1]);

        // Start recursive listing
        o.start();
        o.writeToFile( file );
        file &lt;&lt; &quot;\n\nContent: &quot; &lt;&lt; o.rFiles() &lt;&lt; &quot; Files, &quot; &lt;&lt; o.rDirectories() &lt;&lt; &quot; Directories.\n&quot;;
        file.close();

        std::cout &lt;&lt; &quot;Total time for execution: &quot; &lt;&lt; tim.ElapsedTime() &lt;&lt; &quot; seconds&quot; &lt;&lt; std::endl;

        /* o.sortTree();
           o.displayTree();
           o.setNewRoot(&quot;C:\\&quot;);
           o.start();
           o.displayTree(); */
    } catch( Exception&amp; e ) {
        std::cout &lt;&lt; e.what() &lt;&lt; &quot; (&quot; &lt;&lt; e.GetErrorType() &lt;&lt; &quot;)&quot; &lt;&lt; std::endl;
        return -1;
    } catch(...) {
        std::cout &lt;&lt; &quot;Unknown Exception!&quot; &lt;&lt; std::endl;
        return -1;
    }

    return 0;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/topic/252852/dateien-von-hdd-auflisten-und-als-linkliste-speichern</link><generator>RSS for Node</generator><lastBuildDate>Mon, 14 Sep 2026 04:13:33 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/252852.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 25 Oct 2009 14:47:53 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Dateien von HDD auflisten und als Linkliste speichern on Sun, 25 Oct 2009 14:47:53 GMT]]></title><description><![CDATA[<p>Ich suche ein Tool womit ich alle Dateien eines Ordners (mit den Dateien aus Unterordnern) auflisten kann und die Links zu den Dateien in eine .txt Datei abspeichern kann.<br />
z.B.<br />
Ordner\Datei1<br />
Ordner\Ordner1\Datei2</p>
<p>Habe schon sowas ähnliches gefunden, nur das keine Links zu den Dateien gespeichert werden. Vielleicht hat ja jemand so ein Programm oder kann mir beim anpassen des Quelltextes helfen.<br />
Ich kann nur ein wenig C und verstehe deshalb die meisten Funktionen nicht.</p>
<pre><code class="language-cpp">/*
 * This file is part of DirectoryNavigator.
 * Copyright (C) 2005 - 2009 CodePlanet. All rights reserved.
 *
 * DirectoryNavigator is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * DirectoryNavigator is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with DirectoryNavigator.  If not, see &lt;http://www.gnu.org/licenses/&gt;. 
 */

#include &quot;listdir.h&quot;
#include &quot;timer.h&quot;

/**
 * File:          listdir.cpp                                          
 * Description:   Recursively walk through directories, starting        
 *                at a specified path and insert it into a an          
 *                STL-like container class for n-ary trees.           
 * Version:       1.0                                                 
 * Language:      C++, MSVC 8.0                                        
 * Platform:      x86, Windows NT                                      
 * Author:        http://www.codeplanet.eu/              
 */
Item::Item()
{ 
}

Item::~Item()
{
}

// Default dir name display function
void Item::dirsItem(const std::string&amp; dirName) 
{ 
    std::cout &lt;&lt; &quot;\n  &quot; &lt;&lt; dirName  &lt;&lt; std::endl;
}

// Default file data display function
void Item::fileItem(const WIN32_FIND_DATA *findData) 
{
    int filesize = findData-&gt;nFileSizeLow;

    FILETIME ft;
    FileTimeToLocalFileTime(&amp;(findData-&gt;ftLastWriteTime), &amp;ft);
    SYSTEMTIME st;
    FileTimeToSystemTime(&amp;ft, &amp;st);

    std::cout &lt;&lt; &quot;\t&quot;;
    std::cout.setf(std::ios::left, std::ios::adjustfield);
    std::cout &lt;&lt; std::setw(15) &lt;&lt; findData-&gt;cFileName;
    std::cout.setf(std::ios::right, std::ios::adjustfield);
    std::cout &lt;&lt; std::setw(10) &lt;&lt; filesize &lt;&lt; &quot;    &quot;;
    std::cout &lt;&lt; std::setw(2) &lt;&lt; st.wMonth &lt;&lt; &quot;/&quot;
              &lt;&lt; std::setw(2) &lt;&lt; st.wDay &lt;&lt; &quot;/&quot;
              &lt;&lt; std::setw(4) &lt;&lt; st.wYear &lt;&lt; &quot;  &quot;
              &lt;&lt; std::setw(2) &lt;&lt; st.wHour &lt;&lt; &quot;:&quot;
              &lt;&lt; std::setw(2) &lt;&lt; st.wMinute &lt;&lt; std::endl;  
}

// Constructor: Save user's working directory
Navigator::Navigator(std::string r)
: root(r), directories(0), files(0)
{
    // Create first element at the top
    viter.push_back(strTree.begin());                     
    viter.push_back(strTree.insert(viter[0], &quot;&quot;));

    // save user's working directory
    char buffer[256];
    GetCurrentDirectory(256, buffer);
    userDir = buffer;
    p = new Item();
}

// Use alternate Item class
void Navigator::use(Item *dp) 
{ 
    delete p;
    p = dp; 
}

// Destructor: Restore user's working directory
// and delete p
Navigator::~Navigator() 
{  
    SetCurrentDirectory(userDir.c_str()); 
    delete p;
}

// Specify starting directory and initiate walk
void Navigator::start() 
{
    // Convert &quot;.&quot; or &quot;..&quot; into full path name
    char buffer[256];

    if( (root == &quot;.&quot;) || (root == &quot;..&quot;) ) {
        if( !SetCurrentDirectory(root.c_str()) )
            std::cout &lt;&lt; &quot;Could not find directory &quot; &lt;&lt; root &lt;&lt; std::endl;

        GetCurrentDirectory(256, buffer);
        root = buffer;
    }

    // Start recursive directory walk
    walk(root);
}

// Walk directory tree rooted at dir
void Navigator::walk(const std::string &amp;dir) 
{
    char *fileName;
    char curDir[256];
    char fullName[256];
    HANDLE fileHandle;
    WIN32_FIND_DATA findData;
    std::string fileMask = &quot;*.*&quot;;

    // Save current dir so we can restore it
    if( !GetCurrentDirectory(256, curDir) ) 
        return;

    // If the directory name is neither . or .. then
    // change to it, otherwise ignore it                              
    if( (dir != &quot;.&quot;) &amp;&amp; (dir != &quot;..&quot;) ) {
        if(!SetCurrentDirectory(dir.c_str())) 
            return;
    } else {
        return;
    }

    // Print out the current directory name
    if( !GetFullPathName(fileMask.c_str(), 256, fullName, &amp;fileName) ) 
        return;

    std::string tmp(fullName);
    ++directories;

    /* Check if we have more subdirectory's
    if(lastDir.compare(curDir) == 0)      
        std::cout &lt;&lt; &quot;Another Subdirectory!&quot; &lt;&lt; std::endl;
    */
    viter.push_back(strTree.append_child(viter[viter.size()-1], tmp));

    // Loop through all files in the directory
    fileHandle = FindFirstFile(fileMask.c_str(), &amp;findData);

    while( fileHandle != INVALID_HANDLE_VALUE ) {
        // If the name is a directory,
        // recursively walk it. Otherwise print
        // print the file's data
        if( findData.dwFileAttributes &amp; FILE_ATTRIBUTE_DIRECTORY ) {
            // OK, it is a directory
            walk(findData.cFileName);
        } else {
            fileItem(&amp;findData);
        }

        // Loop through remaining entries in the dir
        if( !FindNextFile(fileHandle, &amp;findData) )
            break;
    }

    // Clean up and restore directory
    FindClose(fileHandle);
    SetCurrentDirectory(curDir);
    viter.pop_back();
}

// Write our tree to console
void Navigator::displayTree()
{
    tree&lt;std::string&gt;::pre_order_iterator it = strTree.begin(), end = strTree.end();

    if( !strTree.is_valid(it) ) {
        throw Exception(Exception::INVALID_ARGUMENT, &quot;Navigator: Could not display tree. No valid tree object!&quot;);
        return;
    }

    int rootdepth = strTree.depth(it);
    std::cout &lt;&lt; &quot;---------------------------------------------------&quot; &lt;&lt; std::endl;
    while( it != end ) {
        for(int i=0; i &lt; strTree.depth(it)-rootdepth; ++i) 
            std::cout &lt;&lt; &quot;  &quot;;
        std::cout &lt;&lt; (*it) &lt;&lt; std::endl &lt;&lt; std::flush;
        ++it;
    }
    std::cout &lt;&lt; &quot;---------------------------------------------------&quot; &lt;&lt; std::endl;
}

// Write our tree into a file
void Navigator::writeToFile(std::ofstream&amp; filestream)
{
    tree&lt;std::string&gt;::pre_order_iterator it = strTree.begin(), end = strTree.end();

    if( !strTree.is_valid(it) ) 
        throw Exception(Exception::INVALID_ARGUMENT, &quot;Navigator: Could not write tree to file. No valid tree object!&quot;);

    int rootdepth = strTree.depth(it);
    filestream &lt;&lt; &quot;\nDirectory Tree Structure of &quot; &lt;&lt; root &lt;&lt; &quot;:&quot; &lt;&lt; std::endl; 
    filestream &lt;&lt; &quot;---------------------------------------------------&quot; &lt;&lt; std::endl;
    while( it != end ) {
      for( int i=0; i &lt; strTree.depth(it) - rootdepth; ++i ) 
         filestream &lt;&lt; &quot;  &quot;;
      filestream &lt;&lt; (*it) &lt;&lt; std::endl &lt;&lt; std::flush;
      ++it;
    }
    filestream &lt;&lt; std::endl;    
}

// Insert file data to our tree
void Navigator::fileItem(const WIN32_FIND_DATA *findData)
{
    int filesize = findData-&gt;nFileSizeLow; 

    FILETIME ft;
    FileTimeToLocalFileTime(&amp;(findData-&gt;ftLastWriteTime), &amp;ft);
    SYSTEMTIME st;
    FileTimeToSystemTime(&amp;ft, &amp;st);

    std::string fileData(findData-&gt;cFileName);

    // Need some Conversion ;)
    std::stringstream ss;

    //ss &lt;&lt; std::setw(10) &lt;&lt; filesize &lt;&lt; &quot;    &quot; 
    //   &lt;&lt; std::setw(2) &lt;&lt; std::setfill('0') &lt;&lt; st.wDay &lt;&lt; &quot;/&quot;
    //   &lt;&lt; std::setw(2) &lt;&lt; st.wMonth &lt;&lt; &quot;/&quot;
    //   &lt;&lt; std::setw(4) &lt;&lt; st.wYear &lt;&lt; &quot;  &quot;
    //   &lt;&lt; std::setw(2) &lt;&lt; st.wHour &lt;&lt; &quot;:&quot;
    //   &lt;&lt; std::setw(2) &lt;&lt; st.wMinute; 

    fileData += ss.str();

    strTree.append_child( viter[viter.size()-1], fileData );
    ++files;
}

void Navigator::sortTree()
{
    // Sorting the entire tree, level by level    
    strTree.sort( strTree.begin(), strTree.end(), true ); 
}

void Navigator::setNewRoot(const std::string&amp; nroot)
{ 
    // Clear up data
    strTree.clear();
    viter.clear();

    if( strTree.empty() &amp;&amp; viter.empty() ) {
        root = nroot; 

        // Create first element at the top
        viter.push_back(strTree.begin());                     
        viter.push_back(strTree.insert(viter[0], &quot;&quot;));
    } else {
        throw Exception(Exception::OTHER_ERROR, &quot;Navigator: setNewRoot failed!&quot;);
    }
}
</code></pre>
<pre><code class="language-cpp">/*
 * This file is part of DirectoryNavigator.
 * Copyright (C) 2005 - 2009 CodePlanet. All rights reserved.
 *
 * DirectoryNavigator is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * DirectoryNavigator is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with DirectoryNavigator.  If not, see &lt;http://www.gnu.org/licenses/&gt;. 
 */

#include &quot;listdir.h&quot;
#include &quot;timer.h&quot;

/**
 * File:          main.cpp                                             
 * Description:   This is the main class. It shows some examples how to    
 *                use the other classes like Navigator and Timer. 
 * Version:       1.0                                                  
 * Language:      C++, MSVC 8.0                                        
 * Platform:      x86, Windows NT                                  
 * Author:        http://www.codeplanet.eu/ 
 */
int main(int argc, char *argv[]) 
{
    try {
        if(argc &lt; 2) 
            throw InvalidArgument(&quot;Please enter one starting path!&quot;);

        unsigned long dwResult = GetFileAttributes(argv[1]);

        if(dwResult == INVALID_FILE_ATTRIBUTES)
            throw InvalidArgument(&quot;Please enter a valid path!&quot;);
        else if(!(dwResult &amp; FILE_ATTRIBUTE_DIRECTORY))
            throw InvalidArgument(&quot;This is not a directory!&quot;);

        const char filename[] = &quot;output.txt&quot;;
        SYSTEMTIME st;
        GetSystemTime(&amp;st);  
        std::ofstream file(filename, std::ios_base::out);
        Timer tim;

        tim.StartTimer();   // Start a timer

        if( !file )
            throw Exception(Exception::IO_ERROR, &quot;Error opening file!&quot;);

        file &lt;&lt; &quot;Listing generated at: &quot; &lt;&lt; st.wDay  &lt;&lt; &quot;.&quot; &lt;&lt; st.wMonth&lt;&lt; &quot;.&quot; &lt;&lt; st.wYear 
             &lt;&lt; &quot; - &quot; &lt;&lt; std::setw(2) &lt;&lt; std::setfill('0') &lt;&lt; st.wHour &lt;&lt; &quot;:&quot;
             &lt;&lt; std::setw(2) &lt;&lt; st.wMinute &lt;&lt; &quot;:&quot; &lt;&lt; std::setw(2) 
             &lt;&lt; st.wSecond &lt;&lt; &quot; (GMT)&quot; &lt;&lt; std::setfill(' ') &lt;&lt; std::endl;

        // Create new instance
        Navigator o(argv[1]);

        // Start recursive listing
        o.start();
        o.writeToFile( file );
        file &lt;&lt; &quot;\n\nContent: &quot; &lt;&lt; o.rFiles() &lt;&lt; &quot; Files, &quot; &lt;&lt; o.rDirectories() &lt;&lt; &quot; Directories.\n&quot;;
        file.close();

        std::cout &lt;&lt; &quot;Total time for execution: &quot; &lt;&lt; tim.ElapsedTime() &lt;&lt; &quot; seconds&quot; &lt;&lt; std::endl;

        /* o.sortTree();
           o.displayTree();
           o.setNewRoot(&quot;C:\\&quot;);
           o.start();
           o.displayTree(); */
    } catch( Exception&amp; e ) {
        std::cout &lt;&lt; e.what() &lt;&lt; &quot; (&quot; &lt;&lt; e.GetErrorType() &lt;&lt; &quot;)&quot; &lt;&lt; std::endl;
        return -1;
    } catch(...) {
        std::cout &lt;&lt; &quot;Unknown Exception!&quot; &lt;&lt; std::endl;
        return -1;
    }

    return 0;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1798018</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1798018</guid><dc:creator><![CDATA[TVJunkie]]></dc:creator><pubDate>Sun, 25 Oct 2009 14:47:53 GMT</pubDate></item><item><title><![CDATA[Reply to Dateien von HDD auflisten und als Linkliste speichern on Sun, 25 Oct 2009 15:12:23 GMT]]></title><description><![CDATA[<p>dir c:\ /S /B &gt; dateien.txt</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1798030</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1798030</guid><dc:creator><![CDATA[volkard]]></dc:creator><pubDate>Sun, 25 Oct 2009 15:12:23 GMT</pubDate></item><item><title><![CDATA[Reply to Dateien von HDD auflisten und als Linkliste speichern on Sun, 25 Oct 2009 16:39:37 GMT]]></title><description><![CDATA[<p><img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f62e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--face_with_open_mouth"
      title=":open_mouth:"
      alt="😮"
    /> Wieso einfach, wenn es auch kompliziert geht.<br />
Hatte es schon mit &quot;tree&quot; probiert.</p>
<p>Kann man den Laufwerksbuchstaben auch nicht mit speichern?</p>
<p>also so:<br />
Ordner/Datei.txt</p>
<p>Schonmal vielen Dank volkard.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1798094</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1798094</guid><dc:creator><![CDATA[TVJunkie]]></dc:creator><pubDate>Sun, 25 Oct 2009 16:39:37 GMT</pubDate></item><item><title><![CDATA[Reply to Dateien von HDD auflisten und als Linkliste speichern on Sun, 25 Oct 2009 18:03:57 GMT]]></title><description><![CDATA[<p>TVJunkie schrieb:</p>
<blockquote>
<p>Kann man den Laufwerksbuchstaben auch nicht mit speichern?</p>
</blockquote>
<p>Jetzt wären Deine superlativen Programmierkenntnisse angebracht, daß Du die dateien.txt zeilenweise einliest und jede Zeile ohne die ersten beiden Zeichen wieder ausgibst.</p>
<pre><code class="language-cpp">int main(){
   string zeile;
   while(in&gt;&gt;zeile){
      cout&lt;&lt;zeile.substr(2,-1)&lt;&lt;'\n';//oder so
   }
}
</code></pre>
<p>und dann<br />
dir c:\ /S /B | abschnippler &gt; dateien.txt</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1798139</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1798139</guid><dc:creator><![CDATA[volkard]]></dc:creator><pubDate>Sun, 25 Oct 2009 18:03:57 GMT</pubDate></item><item><title><![CDATA[Reply to Dateien von HDD auflisten und als Linkliste speichern on Sun, 25 Oct 2009 19:54:37 GMT]]></title><description><![CDATA[<p>volkard schrieb:</p>
<blockquote>
<pre><code class="language-cpp">cout&lt;&lt;zeile.substr(2,-1)&lt;&lt;'\n';//oder so
</code></pre>
</blockquote>
<p><code>zeile.substr(2);</code> reicht doch - und produziert weder warnings noch kann(könnte) es bei langen strings das ende abschneiden</p>
<p>bb</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1798223</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1798223</guid><dc:creator><![CDATA[unskilled]]></dc:creator><pubDate>Sun, 25 Oct 2009 19:54:37 GMT</pubDate></item><item><title><![CDATA[Reply to Dateien von HDD auflisten und als Linkliste speichern on Sun, 25 Oct 2009 20:20:20 GMT]]></title><description><![CDATA[<p>Ich steige noch nicht ganz durch, wo denn der Pfad zu der Datei (die ich einlesen will) angegeben wird, damit das Programm weiss, was es öffnen soll.</p>
<p>Aber wenn ich das sowieso neu einlesen muss kann ich das auch in dem eigentlichen Programm machen, wozu ich die Linkliste brauche.</p>
<p>Mache dazu mal ein neues Thema auf.</p>
<p>Erstmal Danke an euch beide.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1798235</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1798235</guid><dc:creator><![CDATA[TVJunkie]]></dc:creator><pubDate>Sun, 25 Oct 2009 20:20:20 GMT</pubDate></item></channel></rss>