<?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[code zu lang!!! O.o]]></title><description><![CDATA[<p>hi,<br />
ich habe eine Methode zum auslesen eines Ordners + Unterordner gechrieben.<br />
Einmal in Java und einmal in c++</p>
<pre><code class="language-java">public ArrayList&lt;File&gt; getAllFiles( File path ) {

            ArrayList&lt;File&gt; ret = new ArrayList&lt;File&gt;();
            File[] files = path.listFiles();

            for ( File f : files ) 

                if ( f.isDirectory() ) 
                    ret.addAll( getAllFiles( f ) );

                else 
                	ret.add( f );

            return ret;
        }
</code></pre>
<pre><code class="language-cpp">vector&lt;string&gt; Filter::ListFolder(string path){

	HANDLE fHandle;
	WIN32_FIND_DATA wfd;

	char *src = (char*)(path.c_str());
	LPCWSTR lpszsrc = (LPCWSTR)src;

	fHandle = FindFirstFile(src,&amp;wfd);

	vector&lt;string&gt; list;

	do{

    if (!( (wfd.cFileName[0]=='.') &amp;&amp; ( (wfd.cFileName[1]=='.' &amp;&amp; wfd.cFileName[2]==0) || wfd.cFileName[1]==0 ) )){

        if (wfd.dwFileAttributes &amp; FILE_ATTRIBUTE_DIRECTORY){

			if( path.at( path.length()-1 ) == '*' )
				path.erase( path.length() - 1 );

			string next = path +  wfd.cFileName + &quot;\\*&quot;;

			vector&lt;string&gt; buffer = this-&gt;ListFolder(next);
			list.insert(list.end(), buffer.begin(), buffer.end() );
			buffer.resize(NULL);

        }
        else{

			if( path.at( path.length()-1 ) == '*' )
				path.erase( path.length() - 1 );

			string element = path +  wfd.cFileName;
			list.push_back(element);
        }
    }
	}
	while (FindNextFile(fHandle,&amp;wfd));
	FindClose(fHandle);

	return list;
}
</code></pre>
<p>Jetzt ist das gleiche Prinzip in c++ etwas länger geworden... <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f603.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--grinning_face_with_big_eyes"
      title=":D"
      alt="😃"
    /><br />
wäre nett, wenn sich mal jemand die Mühe macht und mir sagt,<br />
wo man etwas hätte kürzer gestalten können <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/topic/280782/code-zu-lang-o-o</link><generator>RSS for Node</generator><lastBuildDate>Sun, 23 Aug 2026 23:25:08 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/280782.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 21 Jan 2011 12:27:28 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to code zu lang!!! O.o on Fri, 21 Jan 2011 12:27:28 GMT]]></title><description><![CDATA[<p>hi,<br />
ich habe eine Methode zum auslesen eines Ordners + Unterordner gechrieben.<br />
Einmal in Java und einmal in c++</p>
<pre><code class="language-java">public ArrayList&lt;File&gt; getAllFiles( File path ) {

            ArrayList&lt;File&gt; ret = new ArrayList&lt;File&gt;();
            File[] files = path.listFiles();

            for ( File f : files ) 

                if ( f.isDirectory() ) 
                    ret.addAll( getAllFiles( f ) );

                else 
                	ret.add( f );

            return ret;
        }
</code></pre>
<pre><code class="language-cpp">vector&lt;string&gt; Filter::ListFolder(string path){

	HANDLE fHandle;
	WIN32_FIND_DATA wfd;

	char *src = (char*)(path.c_str());
	LPCWSTR lpszsrc = (LPCWSTR)src;

	fHandle = FindFirstFile(src,&amp;wfd);

	vector&lt;string&gt; list;

	do{

    if (!( (wfd.cFileName[0]=='.') &amp;&amp; ( (wfd.cFileName[1]=='.' &amp;&amp; wfd.cFileName[2]==0) || wfd.cFileName[1]==0 ) )){

        if (wfd.dwFileAttributes &amp; FILE_ATTRIBUTE_DIRECTORY){

			if( path.at( path.length()-1 ) == '*' )
				path.erase( path.length() - 1 );

			string next = path +  wfd.cFileName + &quot;\\*&quot;;

			vector&lt;string&gt; buffer = this-&gt;ListFolder(next);
			list.insert(list.end(), buffer.begin(), buffer.end() );
			buffer.resize(NULL);

        }
        else{

			if( path.at( path.length()-1 ) == '*' )
				path.erase( path.length() - 1 );

			string element = path +  wfd.cFileName;
			list.push_back(element);
        }
    }
	}
	while (FindNextFile(fHandle,&amp;wfd));
	FindClose(fHandle);

	return list;
}
</code></pre>
<p>Jetzt ist das gleiche Prinzip in c++ etwas länger geworden... <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f603.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--grinning_face_with_big_eyes"
      title=":D"
      alt="😃"
    /><br />
wäre nett, wenn sich mal jemand die Mühe macht und mir sagt,<br />
wo man etwas hätte kürzer gestalten können <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2009699</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2009699</guid><dc:creator><![CDATA[oehm]]></dc:creator><pubDate>Fri, 21 Jan 2011 12:27:28 GMT</pubDate></item><item><title><![CDATA[Reply to code zu lang!!! O.o on Fri, 21 Jan 2011 12:32:37 GMT]]></title><description><![CDATA[<p>Welcome to C++!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2009701</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2009701</guid><dc:creator><![CDATA[asdfasd]]></dc:creator><pubDate>Fri, 21 Jan 2011 12:32:37 GMT</pubDate></item><item><title><![CDATA[Reply to code zu lang!!! O.o on Fri, 21 Jan 2011 12:36:21 GMT]]></title><description><![CDATA[<p>Das hat ja mit C++ nichts zu tun. Dein Problem liegt in der Umsetzung mit der WinApi. Ich würde mich übrigens auch nicht wundern, wenn der Java-Code einfach nur die Aufrufe gekapselt hat.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2009705</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2009705</guid><dc:creator><![CDATA[Paul Müller]]></dc:creator><pubDate>Fri, 21 Jan 2011 12:36:21 GMT</pubDate></item><item><title><![CDATA[Reply to code zu lang!!! O.o on Fri, 21 Jan 2011 12:40:36 GMT]]></title><description><![CDATA[<p>TROLLLL ! ??</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2009706</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2009706</guid><dc:creator><![CDATA[Anti Troll 2011]]></dc:creator><pubDate>Fri, 21 Jan 2011 12:40:36 GMT</pubDate></item><item><title><![CDATA[Reply to code zu lang!!! O.o on Fri, 21 Jan 2011 12:42:44 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">char *src = (char*)(path.c_str()); 
LPCWSTR lpszsrc = (LPCWSTR)src;
</code></pre>
<p>Was soll denn das? Das ist komplett falsch!<br />
c_str() gibt einen const char* zurück und kann nicht als char* benutzt werden.</p>
<p>Ausserdem fehlt nach dem Aufruf von FindFirstFile(..) die Prüfung des Rückgabewertes (handle).</p>
<p>Falls Du zwischen Unicode / Multibyte Strings konvertieren musst:<br />
<a href="http://www.c-plusplus.net/forum/276277" rel="nofollow">http://www.c-plusplus.net/forum/276277</a><br />
<a href="http://www.c-plusplus.net/forum/260205-10" rel="nofollow">http://www.c-plusplus.net/forum/260205-10</a></p>
<p>Jedoch geht das bei Dir auch ohne:<br />
Verwende doch std::wstring, wenn Du Unicode benutzen möchtest - oder ein andere vernünftige Lösung.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2009710</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2009710</guid><dc:creator><![CDATA[theta]]></dc:creator><pubDate>Fri, 21 Jan 2011 12:42:44 GMT</pubDate></item><item><title><![CDATA[Reply to code zu lang!!! O.o on Fri, 21 Jan 2011 12:50:46 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">vector&lt;string&gt; listFolder( string Path ) {
	vector&lt;string&gt; Files;
	for ( directory_iterator i(Path); i!=directory_iterator(); ++i )
		if ( is_regular( i-&gt;status() ) )
			Files.push_back( i-&gt;path().filename() );
		else {
			vector&lt;string&gt; NextFiles = listFolder( Path + &quot;/&quot; + i-&gt;path().filename() );
			Files.insert( Files.end(), NextFiles.begin(), NextFiles.end() );
		}
	return Files;
}
</code></pre>
<p>Mit</p>
<pre><code class="language-cpp">#include &lt;boost/filesystem.hpp&gt;
#include &lt;vector&gt;
#include &lt;string&gt;
using namespace std;
using namespace boost::filesystem;
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2009716</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2009716</guid><dc:creator><![CDATA[fdfdfdsadf]]></dc:creator><pubDate>Fri, 21 Jan 2011 12:50:46 GMT</pubDate></item><item><title><![CDATA[Reply to code zu lang!!! O.o on Fri, 21 Jan 2011 13:11:20 GMT]]></title><description><![CDATA[<p>theta schrieb:</p>
<blockquote>
<pre><code class="language-cpp">char *src = (char*)(path.c_str()); 
LPCWSTR lpszsrc = (LPCWSTR)src;
</code></pre>
<p>Was soll denn das? Das ist komplett falsch!<br />
c_str() gibt einen const char* zurück und kann nicht als char* benutzt werden.</p>
<p>Ausserdem fehlt nach dem Aufruf von FindFirstFile(..) die Prüfung des Rückgabewertes (handle).</p>
<p>Falls Du zwischen Unicode / Multibyte Strings konvertieren musst:<br />
<a href="http://www.c-plusplus.net/forum/276277" rel="nofollow">http://www.c-plusplus.net/forum/276277</a><br />
<a href="http://www.c-plusplus.net/forum/260205-10" rel="nofollow">http://www.c-plusplus.net/forum/260205-10</a></p>
<p>Jedoch geht das bei Dir auch ohne:<br />
Verwende doch std::wstring, wenn Du Unicode benutzen möchtest - oder ein andere vernünftige Lösung.</p>
</blockquote>
<p>naja er wandelt es ja in ein const ptr wieder um,...</p>
<p>ansonsten:</p>
<pre><code class="language-cpp">typedef const wchar_t* LPCWSTR; 
//&lt;----
std::wstring Path;

LPCWSTR lpszsrc = path.c_str(); 
//std::wstring::c_str .. const wchar_t* std::basic_string&lt;wchar_t,,std::char_traits&lt;wchar_t&gt;,std::allocator&lt;wchar_t&gt; &gt;::c_str(void) const
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2009721</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2009721</guid><dc:creator><![CDATA[zeusosc]]></dc:creator><pubDate>Fri, 21 Jan 2011 13:11:20 GMT</pubDate></item><item><title><![CDATA[Reply to code zu lang!!! O.o on Fri, 21 Jan 2011 13:13:57 GMT]]></title><description><![CDATA[<p>ganz großes danke @ fdfdfdsadf</p>
<p>Das schaut echt top aus!!! <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /></p>
<p>theta schrieb:</p>
<blockquote>
<p>Was soll denn das? Das ist komplett falsch!</p>
</blockquote>
<p>komplett falsch, würde ich jetzt nicht sagen,<br />
sonst hätte es vermutlich nicht funktioniert.</p>
<p>Anti Troll 2011 schrieb:</p>
<blockquote>
<p>TROLLLL ! ??</p>
</blockquote>
<p>Wie manche Leute sich immer gleich in<br />
ihrer Existenz bedroht fühlen <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f603.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--grinning_face_with_big_eyes"
      title=":D"
      alt="😃"
    /></p>
<p>Ich wollte einfach wissen, wie man das Ganze professioneller lösen kann.<br />
Danke noch mal für eure Hilfe.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2009722</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2009722</guid><dc:creator><![CDATA[oehm]]></dc:creator><pubDate>Fri, 21 Jan 2011 13:13:57 GMT</pubDate></item><item><title><![CDATA[Reply to code zu lang!!! O.o on Fri, 21 Jan 2011 13:30:26 GMT]]></title><description><![CDATA[<blockquote>
<p>komplett falsch, würde ich jetzt nicht sagen,<br />
sonst hätte es vermutlich nicht funktioniert.</p>
</blockquote>
<p>Oh doch...komplett falsch. Und nur weil es gerade ohne sichtbaren Fehler läuft heisst das noch lange nicht, dass es korrekt ist.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2009733</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2009733</guid><dc:creator><![CDATA[theta]]></dc:creator><pubDate>Fri, 21 Jan 2011 13:30:26 GMT</pubDate></item><item><title><![CDATA[Reply to code zu lang!!! O.o on Fri, 21 Jan 2011 13:31:00 GMT]]></title><description><![CDATA[<p>I accept your challenge. Prepare to die! Muahaha! Chicken Scheme:</p>
<pre><code>(use srfi-1 posix)

(define (getAll dir)
    (append-map
      (lambda (x) (if (directory? x) (getAll (directory x)) (list x)))
      dir))

call: (getAll (list (current-directory)))
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2009734</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2009734</guid><dc:creator><![CDATA[knivil]]></dc:creator><pubDate>Fri, 21 Jan 2011 13:31:00 GMT</pubDate></item><item><title><![CDATA[Reply to code zu lang!!! O.o on Fri, 21 Jan 2011 13:46:03 GMT]]></title><description><![CDATA[<p>u die first</p>
<p>BASH schrieb:</p>
<blockquote>
<p>$(ls -R)</p>
</blockquote>
]]></description><link>https://www.c-plusplus.net/forum/post/2009743</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2009743</guid><dc:creator><![CDATA[competitor]]></dc:creator><pubDate>Fri, 21 Jan 2011 13:46:03 GMT</pubDate></item><item><title><![CDATA[Reply to code zu lang!!! O.o on Fri, 21 Jan 2011 13:52:44 GMT]]></title><description><![CDATA[<p>@ competitor<br />
?????</p>
<pre><code class="language-cpp">#include&lt;iostream&gt;

int main()
{
    System(&quot;$(ls -R)&quot;)
    return 0;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2009747</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2009747</guid><dc:creator><![CDATA[h0000h0h0000]]></dc:creator><pubDate>Fri, 21 Jan 2011 13:52:44 GMT</pubDate></item><item><title><![CDATA[Reply to code zu lang!!! O.o on Fri, 21 Jan 2011 13:58:54 GMT]]></title><description><![CDATA[<p>super!!!</p>
<p>main.bat</p>
<pre><code>dir /s *.* &gt; contents.txt
</code></pre>
<p>sogar gleich in eine txt gespeichert...<br />
BOOOAH <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f603.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--grinning_face_with_big_eyes"
      title=":D"
      alt="😃"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2009751</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2009751</guid><dc:creator><![CDATA[ohem]]></dc:creator><pubDate>Fri, 21 Jan 2011 13:58:54 GMT</pubDate></item><item><title><![CDATA[Reply to code zu lang!!! O.o on Fri, 21 Jan 2011 14:23:00 GMT]]></title><description><![CDATA[<p>h0000h0h0000 schrieb:</p>
<blockquote>
<p>@ competitor<br />
?????</p>
<pre><code class="language-cpp">#include&lt;iostream&gt;

int main()
{
    System(&quot;$(ls -R)&quot;)
    return 0;
}
</code></pre>
</blockquote>
<p>Das bringt dir bloß nichts. Nachdem dein System-Befehl abgearbeitet ist, wird deine Shell geschlossen und das Ergebnis ist weg. Du musst den Befehl schon noch in einem BASH-Script auswerten. Oder die Ausgabe in deine Anwendung pipen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2009758</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2009758</guid><dc:creator><![CDATA[competitor]]></dc:creator><pubDate>Fri, 21 Jan 2011 14:23:00 GMT</pubDate></item><item><title><![CDATA[Reply to code zu lang!!! O.o on Sat, 22 Jan 2011 02:27:43 GMT]]></title><description><![CDATA[<p>Da hier sowieso jeder irgendwas postet,<br />
mal eine nette Lösung in C# <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /></p>
<pre><code class="language-csharp">static void Main(string[] args){

                DirectoryInfo di = new DirectoryInfo(path);
                FileSystemInfo[] dirs = di.GetDirectories();

                foreach (DirectoryInfo diNext in dirs){
                    FileSystemInfo[] files = diNext.GetFiles();

                    foreach (FileSystemInfo fiNext in files)
                        Console.WriteLine(fiNext.Name);
                }}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2010027</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2010027</guid><dc:creator><![CDATA[# &amp;lt;3]]></dc:creator><pubDate>Sat, 22 Jan 2011 02:27:43 GMT</pubDate></item><item><title><![CDATA[Reply to code zu lang!!! O.o on Sat, 22 Jan 2011 02:34:46 GMT]]></title><description><![CDATA[<p>Wo speicherst du die Dateien in eine Liste um sie weiter verarbeiten zu koennen?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2010029</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2010029</guid><dc:creator><![CDATA[knivil]]></dc:creator><pubDate>Sat, 22 Jan 2011 02:34:46 GMT</pubDate></item><item><title><![CDATA[Reply to code zu lang!!! O.o on Sat, 22 Jan 2011 02:41:11 GMT]]></title><description><![CDATA[<p>knivil schrieb:</p>
<blockquote>
<p>Wo speicherst du die Dateien in eine Liste um sie weiter verarbeiten zu koennen?</p>
</blockquote>
<p>stimmt! Habe keine Liste, aber theoretisch muss man ja nur<br />
die Console.WriteLine Zeile ersetzen. <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2010030</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2010030</guid><dc:creator><![CDATA[# &amp;lt;3]]></dc:creator><pubDate>Sat, 22 Jan 2011 02:41:11 GMT</pubDate></item><item><title><![CDATA[Reply to code zu lang!!! O.o on Sat, 22 Jan 2011 13:08:07 GMT]]></title><description><![CDATA[<p>Hier mit Liste und dem Inhalt von allen Unterordnern <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /></p>
<pre><code class="language-csharp">public static List&lt;FileSystemInfo&gt; ListContents(String path)
        {
            List&lt;FileSystemInfo&gt; contents = new List&lt;FileSystemInfo&gt;();

            DirectoryInfo di = new DirectoryInfo(path);
            FileSystemInfo[] files = di.GetFiles();

            contents.AddRange(files);

            FileSystemInfo[] dirs = di.GetDirectories();

            foreach (DirectoryInfo diNext in dirs)
                contents.AddRange(ListContents(diNext.FullName));

            return contents;
        }
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2010127</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2010127</guid><dc:creator><![CDATA[oehm]]></dc:creator><pubDate>Sat, 22 Jan 2011 13:08:07 GMT</pubDate></item></channel></rss>