www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/04/11/14:50:59

From: "DooMWiz" <DooMWiz AT TicNet DOT Com>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: which function can return the directory of the .exe ?
Date: Sun, 11 Apr 1999 13:19:44 -0500
Organization: The Internet Connection - ticnet.com (using Airnews.net!)
Lines: 63
Message-ID: <21EF89438D8F2E17.6E21802C5B5E8F7A.0AAE947B36D0BDC6@library-proxy.airnews.net>
X-Orig-Message-ID: <7eqp80$p50 AT library DOT airnews DOT net>
References: <7elgcd$4bv$1 AT wanadoo DOT fr>
Abuse-Reports-To: abuse at ticnet.com to report improper postings
NNTP-Proxy-Relay: library.airnews.net
NNTP-Posting-Time: Sun Apr 11 13:21:53 1999
NNTP-Posting-Host: !b AT ra4F\J/Q3WY& (Encoded at Airnews!)
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 5.00.2014.211
X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2014.211
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

CORNU.Nicolas <CORNU DOT Nicolas AT wanadoo DOT fr> wrote in message
news:7elgcd$4bv$1 AT wanadoo DOT fr...
> i need the name of the function which return
> the directory of the apllication: .exe

AFAIK, there is no function to return the directory of an application.  I
made such a function for DDE (doom editor), so it has the QuitDDE_Error
function call in it--change it to whatever you want...  There's also no
guarantee it works, even though it runs perfectly in DDE. =)  BTW, just pass
any full filename + path to this function, and it modifies the
full_file_path....can be changed, of course.  If you want to pass the
filename of the .exe running (user could have changed it from default,
etc.), then "#include <crt0.h>" and do something like "path =
strdup(__crt0_argv[0]);", then pass path to get_path().  =)


Well, here it is:


char *get_path(char *full_file_path)
{
  char *path, *path_sep[50], **sep=&full_file_path;
  unsigned int path_sep_num = 0, path_add, char_add, string_char_add = 0;
  short int runable;

  path = (char*)malloc(512);
  if (path==NULL)
     QuitDDE_Error(LOWMEM, "Can't allocate enough memory for get_path!");

  while ((path_sep[path_sep_num] = strsep(sep, "/"))) {
        path_sep_num++;
  }

  for (path_add = 0; path_add < (path_sep_num-1); path_add++)
  {
    for (char_add = 0; char_add < strlen(path_sep[path_add]); char_add++)
    {
         path[string_char_add] = path_sep[path_add][char_add];
         string_char_add++;
    }
    path[string_char_add] = '/';
    string_char_add++;
  }
  path[string_char_add] = '\0';

  full_file_path = strdup(path);
  free(path);

  return full_file_path;
}


--

--DooMWiz--
Doom Development Environment @
http://dde.tsx.org






- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019