Author Topic: Saving a file without an extension  (Read 4149 times)

sethjackson

  • Guest
Saving a file without an extension
« on: November 21, 2006, 05:46:33 pm »
Recently I saved some files that didn't have an extension on the end (*.cpp, *.txt etc.).
I did File -> New -> Empty file. (added the file to the active project)
I typed in foo as the filename, but C::B saved the file as foo.a.c.
I would expect C::B to tack one extension on the end, but not two (Actually it would be nice if C::B just saved it as foo (no extension), but that is another story).

Is this supposed to happen?

BTW after looking at the code I think the problem (I'm assuming this is a problem) is somewhere in cbEditor::SaveAs(). Maybe with the wxFileDialog.........

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9615
Re: Saving a file without an extension
« Reply #1 on: November 22, 2006, 06:50:11 pm »
Agreed. That's weired. It seems to be related to the number of file extensions (wildcards). If you reduce this, it works properly again. I checked the wildcard string - it get's computed correctly though. So I'd say it's not our fault, but I wouldn't implement a hack around checking to see if the last wildcard (which is always "all files" is selected and then remove the additional file extensions. Let's hope it get's fixed in an upcoming wxWidgets release.
With regards, Morten.

Edit: I just found this piece of code inside wxWidgets:
Code
            wxString::size_type nDot = m_wildCard.find(_T("*."));
            if ( nDot != wxString::npos )
                nDot++;
            else
                nDot = 0;
We *do* have file masks that do not have a dot, e.g. "*Makefile" and "*.py;*SConstruct;*SConscript". MAybe it's our fault...?!
« Last Edit: November 22, 2006, 06:55:57 pm by MortenMacFly »
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: http://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: http://wiki.codeblocks.org/index.php?title=FAQ

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9615
Re: Saving a file without an extension
« Reply #2 on: November 22, 2006, 06:59:27 pm »
Bingo!!! "Python files|*.py;*SConstruct;*SConscript|" is the culprit. Adding this to any wxFileDialog will result in the strange behaviour for "All files". You can try with using for a wildcard masks:
Code
Filters = _T("AngelScript files|*.as|Batch files|*.bat;*.cmd;*.nt|Make files|*Makefile;*.mak|Python files|*.py;*SConstruct;*SConscript|All files|*.*");
This won't work if you select "All files".
So - I'd say we have to fix the file masks (I believe the originate from the lexers)!
With regards, Morten.
« Last Edit: November 22, 2006, 07:26:52 pm by MortenMacFly »
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: http://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: http://wiki.codeblocks.org/index.php?title=FAQ

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9615
Re: Saving a file without an extension
« Reply #3 on: November 22, 2006, 07:54:41 pm »
now it has begun to become *really* weired: I've removed the extensions accordingly but: no success! Then I tried again my little demo example with the following wildcard:
Code
Wildcard=AngelScript files|*.as|Batch files|*.bat;*.cmd;*.nt|Make files|*.mak|Python files|*.py|All files|*.*
Which result's in illegal file extensions! Now where is the issue here? As soon as you remove any of these extensions (e.g. "AngelScript files|*.as" it will work again. But this combination (although it's fully correct) won't work.

Somebody out there who has a glue what's going on here???

With regards, Morten.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: http://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: http://wiki.codeblocks.org/index.php?title=FAQ

Offline Game_Ender

  • Lives here!
  • ****
  • Posts: 551
Re: Saving a file without an extension
« Reply #4 on: November 22, 2006, 09:24:39 pm »
There is a bug somewhere in the wxWidgets dialog and wildcards parsing.  Last time I used it was with wxMac 2.6.3 with STL enabled.  Which meant that wxString throws exceptions if you index them wrong, and everything time I tried to use the wildcard features it threw an index out of range exception.  I didn't have to make up a patch, so I just worked around it.  Debugging into wxWidgets or running it threw valgrind will probably reveal the error.  Either that or it is supposed to be used a certain way and we aren't using it that way.

sethjackson

  • Guest
Re: Saving a file without an extension
« Reply #5 on: November 23, 2006, 01:34:31 am »
I wish I did have some code "glue" or even a clue as to what is going on. :P

Code
Wildcard=AngelScript files|*.as|Batch files|*.bat;*.cmd;*.nt|Make files|*.mak|Python files|*.py|All files|*.*

Are you sure that code is right? I thought all the filters had to have a semi-colon after them......
That example doesn't......

http://wxwidgets.org/manuals/2.6.3/wx_wxfiledialog.html#wxfiledialog

EDIT:

Oh oh oh I see it (I think).

Batch files|*.bat;*.cmd;*.nt
« Last Edit: November 23, 2006, 02:32:42 pm by sethjackson »

Offline Der Meister

  • Regular
  • ***
  • Posts: 307
Re: Saving a file without an extension
« Reply #6 on: November 23, 2006, 10:12:48 am »
I don't think so. The example in the documentation you mentioned has them, too:
Code
"BMP and GIF files (*.bmp;*.gif)|*.bmp;*.gif|PNG files (*.png)|*.png"
Real Programmers don't comment their code. If it was hard to write, it should be hard to understand.
Real Programmers don't write in BASIC. Actually, no programmers write in BASIC, after the age of 12.

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9615
Re: Saving a file without an extension
« Reply #7 on: November 23, 2006, 12:23:23 pm »
Oh oh oh I see it (I think).
Batch files|*.bat;*.cmd;*.nt
Nope, this works properly - you can try by just removing the Python file extension it'll suddenly work.
With regards, Morten.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: http://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: http://wiki.codeblocks.org/index.php?title=FAQ