Author Topic: Open filename on command line  (Read 3976 times)

Offline Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2775
Open filename on command line
« on: October 26, 2014, 01:18:59 am »
Can someone tell this thick headed self how to open a file on the command line:

I've tried "codeblocks.exe c:\this.is.a.file"
and
"codeblocks.exe --file=c:\this.is.a.file"

neither works for me.


svn build  rev 9936 (2014-10-10 14:00:08)   gcc 4.6.1 Windows/unicode - 32 bit

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7588
    • My Best Post
Re: Open filename on command line
« Reply #1 on: October 26, 2014, 01:24:58 am »
This almost worked for me.

Code
codeblocks.exe --file="C:\Temp\this.is.a.file"

It got a CB error of
---------------------------
Error
---------------------------
Could not open file C:\Temp\this.is.a.file,
because no extension handler could be found.
---------------------------
OK  
---------------------------

I get the same error with this.
Code
codeblocks.exe --file=C:\Temp\this.is.a.file

Windows 7 32 bit.

Added c file extension and this command worked on opening it in CB

Code
codeblocks.exe --file=C:\Temp\this.is.a.file.c


Tim S.
« Last Edit: October 26, 2014, 01:29:59 am by stahta01 »
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline scarphin

  • Lives here!
  • ****
  • Posts: 644
Re: Open filename on command line
« Reply #2 on: October 26, 2014, 02:04:32 am »
Maybe the file extension should be inserted to cb's extension handler to point to the internal editor? Just a guess!

Offline Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2775
Re: Open filename on command line
« Reply #3 on: October 29, 2014, 06:39:20 pm »
Reading the code(thanks for the hint staht01), CB will only handle certain extentions for which it has handler to open the files.

I circumvented the code with a personal hack, and am happy I can use CB for a generalized editor now.

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re:
« Reply #4 on: October 29, 2014, 07:52:36 pm »
Well a proper solution would be to show the same dialog we do show in case you open a file without extension handler from the file open dialog.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ