DOS program path

This is a discussion on DOS program path within the C++ Programming forums, part of the General Programming Boards category; Using argv[0] on a console program gives you the full pathname. This is good, but I need it in shortened ...

  1. #1
    Kiss the monkey. CodeMonkey's Avatar
    Join Date
    Sep 2001
    Posts
    892

    DOS program path

    Using argv[0] on a console program gives you the full pathname. This is good, but I need it in shortened DOS-style so I can use it in system(). You know, the little '~' and no spaces. Is there a way to do this, or do I need to make my own translator (agh!!)?

  2. #2
    moi
    moi is offline
    Registered User moi's Avatar
    Join Date
    Jul 2002
    Posts
    946

    Re: DOS program path

    Originally posted by CodeMonkey
    Using argv[0] on a console program gives you the full pathname. This is good, but I need it in shortened DOS-style so I can use it in system(). You know, the little '~' and no spaces. Is there a way to do this, or do I need to make my own translator (agh!!)?
    well first of all what argv[0] gives you is implementation-specific. second of all taking "longfoobar.foobar" and shortening it to "longfo~1.foo" does absolutely nothing for you; there is no guaranteed correspondance of any sort between the long file names and their shortened versions. also, what compiler is this? i'm curious because djgpp accepts lfns in system() calls, and obviously any windoze compiler will.
    hello, internet!

  3. #3
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    >>i'm curious because djgpp accepts lfns in system() calls, and obviously any windoze compiler will.
    Hmm... I had a go at this one, and found that long filenames with spaces in them didn't work. I even tried to surround the name with quotes and got no joy. Maybe I'm doing it wrong..... it's too late for me now
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  4. #4
    moi
    moi is offline
    Registered User moi's Avatar
    Join Date
    Jul 2002
    Posts
    946
    Originally posted by Hammer
    >>i'm curious because djgpp accepts lfns in system() calls, and obviously any windoze compiler will.
    Hmm... I had a go at this one, and found that long filenames with spaces in them didn't work. I even tried to surround the name with quotes and got no joy. Maybe I'm doing it wrong..... it's too late for me now
    hmmmm....... i know that djgpp's system() works with long file names, but i had never considered spaces in them.... ugg.
    hello, internet!

  5. #5
    Kiss the monkey. CodeMonkey's Avatar
    Join Date
    Sep 2001
    Posts
    892
    Is there a way to copy a file without system() ?

  6. #6
    Registered User xds4lx's Avatar
    Join Date
    Nov 2001
    Posts
    630
    yes, just read it in and write it out somewhere else.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Double Buffer my DOS program??
    By Yarin in forum C++ Programming
    Replies: 6
    Last Post: 09-10-2007, 10:58 PM
  2. Getting the path file of your program?
    By RedZone in forum C++ Programming
    Replies: 13
    Last Post: 07-23-2006, 11:25 AM
  3. Why does DOS always close after the program completes?
    By 7smurfs in forum C++ Programming
    Replies: 9
    Last Post: 10-22-2004, 01:14 PM
  4. initialising a DOS program from a C enviroment
    By Robert_Ingleby in forum C Programming
    Replies: 5
    Last Post: 03-07-2002, 12:53 PM
  5. DOS program versus DOS console program
    By scromer in forum A Brief History of Cprogramming.com
    Replies: 4
    Last Post: 01-10-2002, 12:42 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21