<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
  <channel>
    <title>'long file names' Thread RSS Feed</title>
    <link>http://www.programmersheaven.com/</link>
    <description>Contains the latest posts from the thread 'long file names' posted on the 'C and C++' forum at Programmer's Heaven.</description>
    <language>en</language>
    <copyright>Copyright 2013 Programmers Heaven</copyright>
    <pubDate>Thu, 20 Jun 2013 04:12:58 -0700</pubDate>
    <lastBuildDate>Thu, 20 Jun 2013 04:12:58 -0700</lastBuildDate>
    <generator>Argotic Syndication Framework 2007.3.0.1, http://www.codeplex.com/Argotic</generator>
    <docs>http://www.rssboard.org/rss-specification</docs>
    <ttl>360</ttl>
    <image>
      <url>http://www.programmersheaven.com/images/ph.gif</url>
      <title>Programmers Heaven</title>
      <link>http://www.programmersheaven.com/</link>
      <width>88</width>
      <height>31</height>
    </image>
    <item>
      <title>long file names</title>
      <link>http://www.programmersheaven.com/mb/CandCPP/341068/341068/long-file-names/</link>
      <description>Hi,&lt;br /&gt;
&lt;br /&gt;
I am having a problem in opening/accessing a file which has a long name, more than 8 characters of length. How can i access a file:&lt;br /&gt;
1- with a long name&lt;br /&gt;
2- two files with same name(more than 8 characters) having the last charcter different.  For example, originalfile1.txt is shown as origin~1.txt and originalfile2.txt is shown as origin~2.txt in dos. How can i read these two files in C++.&lt;br /&gt;
&lt;br /&gt;
I'll be grateful if anyone can help&lt;br /&gt;
&lt;br /&gt;
Thanks in advance!!&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/CandCPP/341068/341068/long-file-names/</guid>
      <pubDate>Thu, 13 Jul 2006 01:04:12 -0700</pubDate>
      <category>C and C++</category>
    </item>
    <item>
      <title>Re: long file names</title>
      <link>http://www.programmersheaven.com/mb/CandCPP/341068/341076/re-long-file-names/#341076</link>
      <description>&lt;strong&gt;&lt;span style="color: Red;"&gt;This message was edited by stober at  2006-7-13 3:55:1&lt;/span&gt;&lt;/strong&gt;&lt;hr /&gt;&lt;br /&gt;
: Hi,&lt;br /&gt;
: &lt;br /&gt;
: I am having a problem in opening/accessing a file which has a long name, more than 8 characters of length. How can i access a file:&lt;br /&gt;
: 1- with a long name&lt;br /&gt;
: 2- two files with same name(more than 8 characters) having the last charcter different.  For example, originalfile1.txt is shown as origin~1.txt and originalfile2.txt is shown as origin~2.txt in dos. How can i read these two files in C++.&lt;br /&gt;
: &lt;br /&gt;
: I'll be grateful if anyone can help&lt;br /&gt;
: &lt;br /&gt;
: Thanks in advance!!&lt;br /&gt;
: &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
What compiler are you using?  If you are using 16-bit compiler such as Turbo C then you don't have much choice but to use the 8.3 filenames you posted.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/CandCPP/341068/341076/re-long-file-names/#341076</guid>
      <pubDate>Thu, 13 Jul 2006 03:49:33 -0700</pubDate>
      <category>C and C++</category>
    </item>
    <item>
      <title>Re: long file names</title>
      <link>http://www.programmersheaven.com/mb/CandCPP/341068/341514/re-long-file-names/#341514</link>
      <description>: &lt;strong&gt;&lt;span style="color: Red;"&gt;This message was edited by stober at  2006-7-13 3:55:1&lt;/span&gt;&lt;/strong&gt;&lt;hr /&gt;&lt;br /&gt;
: : Hi,&lt;br /&gt;
: : &lt;br /&gt;
: : I am having a problem in opening/accessing a file which has a long name, more than 8 characters of length. How can i access a file:&lt;br /&gt;
: : 1- with a long name&lt;br /&gt;
: : 2- two files with same name(more than 8 characters) having the last charcter different.  For example, originalfile1.txt is shown as origin~1.txt and originalfile2.txt is shown as origin~2.txt in dos. How can i read these two files in C++.&lt;br /&gt;
: : &lt;br /&gt;
: : I'll be grateful if anyone can help&lt;br /&gt;
: : &lt;br /&gt;
: : Thanks in advance!!&lt;br /&gt;
: : &lt;br /&gt;
: &lt;br /&gt;
: &lt;br /&gt;
: What compiler are you using?  If you are using 16-bit compiler such as Turbo C then you don't have much choice but to use the 8.3 filenames you posted.&lt;br /&gt;
: &lt;br /&gt;
: &lt;br /&gt;
: &lt;br /&gt;
Thanks for the reply stober....&lt;br /&gt;
It is an Win32 console application in VC++. Is there a solution for the problem?&lt;br /&gt;
Thanks in advance&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/CandCPP/341068/341514/re-long-file-names/#341514</guid>
      <pubDate>Thu, 20 Jul 2006 05:23:59 -0700</pubDate>
      <category>C and C++</category>
    </item>
    <item>
      <title>Re: long file names</title>
      <link>http://www.programmersheaven.com/mb/CandCPP/341068/341551/re-long-file-names/#341551</link>
      <description>: It is an Win32 console application in VC++. Is there a solution for the problem?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
what version of that compiler?  I know all VC++ 6.0 and newer compilers support long filenames.  VC++ 1.52C is a 16-bit compiler and does not.  It was the last 16-bit compiler Microsoft produced.&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/CandCPP/341068/341551/re-long-file-names/#341551</guid>
      <pubDate>Thu, 20 Jul 2006 16:07:35 -0700</pubDate>
      <category>C and C++</category>
    </item>
    <item>
      <title>Re: long file names</title>
      <link>http://www.programmersheaven.com/mb/CandCPP/341068/341561/re-long-file-names/#341561</link>
      <description>: : It is an Win32 console application in VC++. Is there a solution for the problem?&lt;br /&gt;
: &lt;br /&gt;
: &lt;br /&gt;
: what version of that compiler?  I know all VC++ 6.0 and newer compilers support long filenames.  VC++ 1.52C is a 16-bit compiler and does not.  It was the last 16-bit compiler Microsoft produced.&lt;br /&gt;
: &lt;br /&gt;
&lt;br /&gt;
Its VC++ 6.0. The file with a long name is not being read. Also the one with a space in the name.&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/CandCPP/341068/341561/re-long-file-names/#341561</guid>
      <pubDate>Thu, 20 Jul 2006 21:34:59 -0700</pubDate>
      <category>C and C++</category>
    </item>
    <item>
      <title>Re: long file names</title>
      <link>http://www.programmersheaven.com/mb/CandCPP/341068/341565/re-long-file-names/#341565</link>
      <description>: : : It is an Win32 console application in VC++. Is there a solution for the problem?&lt;br /&gt;
: : &lt;br /&gt;
: : &lt;br /&gt;
: : what version of that compiler?  I know all VC++ 6.0 and newer compilers support long filenames.  VC++ 1.52C is a 16-bit compiler and does not.  It was the last 16-bit compiler Microsoft produced.&lt;br /&gt;
: : &lt;br /&gt;
: &lt;br /&gt;
: Its VC++ 6.0. The file with a long name is not being read. Also the one with a space in the name.&lt;br /&gt;
: &lt;br /&gt;
There shouldn't be any problem reading the file. Post the code, please.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Greets,&lt;br /&gt;
Eric Goldstein&lt;br /&gt;
&lt;a href="http://www.gvh-maatwerk.nl"&gt;http://www.gvh-maatwerk.nl&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/CandCPP/341068/341565/re-long-file-names/#341565</guid>
      <pubDate>Thu, 20 Jul 2006 23:32:46 -0700</pubDate>
      <category>C and C++</category>
    </item>
    <item>
      <title>Re: long file names</title>
      <link>http://www.programmersheaven.com/mb/CandCPP/341068/341571/re-long-file-names/#341571</link>
      <description>: : : : It is an Win32 console application in VC++. Is there a solution for the problem?&lt;br /&gt;
: : : &lt;br /&gt;
: : : &lt;br /&gt;
: : : what version of that compiler?  I know all VC++ 6.0 and newer compilers support long filenames.  VC++ 1.52C is a 16-bit compiler and does not.  It was the last 16-bit compiler Microsoft produced.&lt;br /&gt;
: : : &lt;br /&gt;
: : &lt;br /&gt;
: : Its VC++ 6.0. The file with a long name is not being read. Also the one with a space in the name.&lt;br /&gt;
: : &lt;br /&gt;
: There shouldn't be any problem reading the file. Post the code, please.&lt;br /&gt;
: &lt;br /&gt;
: &lt;br /&gt;
: Greets,&lt;br /&gt;
: Eric Goldstein&lt;br /&gt;
: &lt;a href="http://www.gvh-maatwerk.nl"&gt;http://www.gvh-maatwerk.nl&lt;/a&gt;&lt;br /&gt;
: &lt;br /&gt;
: &lt;br /&gt;
: &lt;br /&gt;
Here's the relevant code:&lt;br /&gt;
&lt;br /&gt;
ifstream ifile;&lt;br /&gt;
&lt;br /&gt;
setpath(argv[1]);//change the working dir&lt;br /&gt;
&lt;br /&gt;
if(get_cdr_structure(format,values))//read the file structure&lt;br /&gt;
	{&lt;br /&gt;
		printlabel();&lt;br /&gt;
&lt;br /&gt;
		//open the cdr&lt;br /&gt;
		ifile.open(argv[2]);&lt;br /&gt;
		if (ifile)&lt;br /&gt;
		{&lt;br /&gt;
			//my code&lt;br /&gt;
		}&lt;br /&gt;
		&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
The code works well if argv[2] contains a short path and a short name &lt;br /&gt;
Thanks in advance&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/CandCPP/341068/341571/re-long-file-names/#341571</guid>
      <pubDate>Fri, 21 Jul 2006 03:14:49 -0700</pubDate>
      <category>C and C++</category>
    </item>
    <item>
      <title>Re: long file names</title>
      <link>http://www.programmersheaven.com/mb/CandCPP/341068/341576/re-long-file-names/#341576</link>
      <description>: : : : : It is an Win32 console application in VC++. Is there a solution for the problem?&lt;br /&gt;
: : : : &lt;br /&gt;
: : : : &lt;br /&gt;
: : : : what version of that compiler?  I know all VC++ 6.0 and newer compilers support long filenames.  VC++ 1.52C is a 16-bit compiler and does not.  It was the last 16-bit compiler Microsoft produced.&lt;br /&gt;
: : : : &lt;br /&gt;
: : : &lt;br /&gt;
: : : Its VC++ 6.0. The file with a long name is not being read. Also the one with a space in the name.&lt;br /&gt;
: : : &lt;br /&gt;
: : There shouldn't be any problem reading the file. Post the code, please.&lt;br /&gt;
: : &lt;br /&gt;
: : &lt;br /&gt;
: : Greets,&lt;br /&gt;
: : Eric Goldstein&lt;br /&gt;
: : &lt;a href="http://www.gvh-maatwerk.nl"&gt;http://www.gvh-maatwerk.nl&lt;/a&gt;&lt;br /&gt;
: : &lt;br /&gt;
: : &lt;br /&gt;
: : &lt;br /&gt;
: Here's the relevant code:&lt;br /&gt;
: &lt;br /&gt;
: ifstream ifile;&lt;br /&gt;
: &lt;br /&gt;
: setpath(argv[1]);//change the working dir&lt;br /&gt;
: &lt;br /&gt;
: if(get_cdr_structure(format,values))//read the file structure&lt;br /&gt;
: 	{&lt;br /&gt;
: 		printlabel();&lt;br /&gt;
: &lt;br /&gt;
: 		//open the cdr&lt;br /&gt;
: 		ifile.open(argv[2]);&lt;br /&gt;
: 		if (ifile)&lt;br /&gt;
: 		{&lt;br /&gt;
: 			//my code&lt;br /&gt;
: 		}&lt;br /&gt;
: 		&lt;br /&gt;
: 	}&lt;br /&gt;
: &lt;br /&gt;
: The code works well if argv[2] contains a short path and a short name &lt;br /&gt;
: Thanks in advance&lt;br /&gt;
&lt;br /&gt;
Aha. Since the file is passed through an argument nd contains spaces, the runtime splits the filename in two or more arguments.&lt;br /&gt;
You can verify that by inspecting argv[3]. You'll see that it contains the rest of the filename.&lt;br /&gt;
Try passing the filename within double quotes.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Greets,&lt;br /&gt;
Eric Goldstein&lt;br /&gt;
&lt;a href="http://www.gvh-maatwerk.nl"&gt;http://www.gvh-maatwerk.nl&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/CandCPP/341068/341576/re-long-file-names/#341576</guid>
      <pubDate>Fri, 21 Jul 2006 05:18:48 -0700</pubDate>
      <category>C and C++</category>
    </item>
    <item>
      <title>Re: long file names</title>
      <link>http://www.programmersheaven.com/mb/CandCPP/341068/341594/re-long-file-names/#341594</link>
      <description>: Aha. Since the file is passed through an argument nd contains spaces, the runtime splits the filename in two or more arguments.&lt;br /&gt;
: You can verify that by inspecting argv[3]. You'll see that it contains the rest of the filename.&lt;br /&gt;
: Try passing the filename within double quotes.&lt;br /&gt;
: &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
you can probably fix this problem by quoting the path on the command line&lt;br /&gt;
&lt;pre class="sourcecode"&gt;
c:&amp;gt;myprogram.exe "an argument with spaces must be quoted here" &amp;lt;Enter&amp;gt;
&lt;/pre&gt;&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/CandCPP/341068/341594/re-long-file-names/#341594</guid>
      <pubDate>Fri, 21 Jul 2006 09:07:13 -0700</pubDate>
      <category>C and C++</category>
    </item>
    <item>
      <title>Re: long file names</title>
      <link>http://www.programmersheaven.com/mb/CandCPP/341068/341754/re-long-file-names/#341754</link>
      <description>: : Aha. Since the file is passed through an argument nd contains spaces, the runtime splits the filename in two or more arguments.&lt;br /&gt;
: : You can verify that by inspecting argv[3]. You'll see that it contains the rest of the filename.&lt;br /&gt;
: : Try passing the filename within double quotes.&lt;br /&gt;
: : &lt;br /&gt;
: &lt;br /&gt;
: &lt;br /&gt;
: you can probably fix this problem by quoting the path on the command line&lt;br /&gt;
: &lt;pre class="sourcecode"&gt;
: c:&amp;gt;myprogram.exe "an argument with spaces must be quoted here" &amp;lt;Enter&amp;gt;
: &lt;/pre&gt;&lt;br /&gt;
: &lt;br /&gt;
&lt;br /&gt;
Thanks stober and tsagld, my problem is solved. I have added the following lines:&lt;br /&gt;
&lt;br /&gt;
strcpy(cdrpath,argv[2]);&lt;br /&gt;
	if(argc&amp;gt;3)&lt;br /&gt;
		for(int i=3;i&amp;lt;argc;i++)&lt;br /&gt;
		{&lt;br /&gt;
			strcat(cdrpath," ");&lt;br /&gt;
			strcat(cdrpath,argv[i]);&lt;br /&gt;
		}&lt;br /&gt;
my code is working well with all sorts of filepaths and filenames.&lt;br /&gt;
Thankyou!!!!!&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/CandCPP/341068/341754/re-long-file-names/#341754</guid>
      <pubDate>Mon, 24 Jul 2006 04:56:11 -0700</pubDate>
      <category>C and C++</category>
    </item>
    <item>
      <title>Re: long file names</title>
      <link>http://www.programmersheaven.com/mb/CandCPP/341068/341820/re-long-file-names/#341820</link>
      <description>&lt;strong&gt;&lt;span style="color: Red;"&gt;This message was edited by tsagld at  2006-7-24 23:37:41&lt;/span&gt;&lt;/strong&gt;&lt;hr /&gt;&lt;br /&gt;
: : : Aha. Since the file is passed through an argument nd contains spaces, the runtime splits the filename in two or more arguments.&lt;br /&gt;
: : : You can verify that by inspecting argv[3]. You'll see that it contains the rest of the filename.&lt;br /&gt;
: : : Try passing the filename within double quotes.&lt;br /&gt;
: : : &lt;br /&gt;
: : &lt;br /&gt;
: : &lt;br /&gt;
: : you can probably fix this problem by quoting the path on the command line&lt;br /&gt;
: : &lt;pre class="sourcecode"&gt;
: : c:&amp;gt;myprogram.exe "an argument with spaces must be quoted here" &amp;lt;Enter&amp;gt;
: : &lt;/pre&gt;&lt;br /&gt;
: : &lt;br /&gt;
: &lt;br /&gt;
: Thanks stober and tsagld, my problem is solved. I have added the following lines:&lt;br /&gt;
&lt;pre class="sourcecode"&gt; 
: strcpy(cdrpath,argv[2]);
: 	if(argc&amp;gt;3) &lt;span style="color: Red;"&gt;this line is not really necessary&lt;/span&gt;
: 		for(int i=3;i&amp;lt;argc;i++)
: 		{
: 			strcat(cdrpath," ");
: 			strcat(cdrpath,argv[i]);
: 		}
&lt;/pre&gt;&lt;br /&gt;
: my code is working well with all sorts of filepaths and filenames.&lt;br /&gt;
: Thankyou!!!!!&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: Red;"&gt;Realize that your code only works if the path is the last argument in the list. Besides that, you have to allocate space for cdrpath before  you know how much space is needed. That's vulnerable to buffer overflows.&lt;br /&gt;
As I stated before, it is better to pass the path between double quotes. Stober gave an example.&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Greets,&lt;br /&gt;
Eric Goldstein&lt;br /&gt;
&lt;a href="http://www.gvh-maatwerk.nl"&gt;http://www.gvh-maatwerk.nl&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/CandCPP/341068/341820/re-long-file-names/#341820</guid>
      <pubDate>Mon, 24 Jul 2006 23:35:32 -0700</pubDate>
      <category>C and C++</category>
    </item>
  </channel>
</rss>