πŸš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #17598

Re: Getting Drive for an given directory

#17598
From: Ed Mulroy [TeamB]
Date: Sat, 22 Mar 2003 17:04
38 lines
2310 bytes
Look at the Windows API function GetFullPathName

For instance, these lines are cut from working code.  The call to
GetFullPathName causes the possibly relative path to be expanded so that it
can be compared to the path to the system directory.  While the source file
is C++, I think these parts are the same for C langauge.

  -----------------
  #include <windows.h>
          :
  const char *not_sys_dir = "Error: \"%s\" is a system directory\n";
  const char *usage = (a string telling saying how to use the prog)
          :
  char  env_buf[MAX_PATH];
  char  full_buf[MAX_PATH];
  char *namep;

  GetFullPathName(dir_name, sizeof(full_buf), full_buf, &namep);
  GetEnvironmentVariable("SystemRoot", env_buf, sizeof(env_buf));

  if (!strnicmp(env_buf, full_buf, lstrlen(env_buf)))
    {
    ErrorMsgFormatted(not_sys_dir, full_buf, usage);
    /* ErrorMsgFormatted is a function provided by the program */
    return 1;
    }
  -----------------

.  Ed

> Luiz Rafael Culik Guimaraes wrote in message
> news:3e7c4c63@newsgroups.borland.com...
>
> > You would first have to resolve the relative path
> > into a full path, and then
> > you can use the VCL's ExtractFileDrive() function.
>
> In C please,  I donοΏ½t use VCL
Technical Details
Message-ID: <3e7c9790$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-03!sn-xit-01!sn-xit-09!supernews.com!iad-peer.news.verio.net!news.verio.net!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mail
References: <3e7bd0f7@newsgroups.borland.com> <3e7bda80@newsgroups.borland.com> <3e7c4c63@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII
X-Google-Thread: 10cc67,dda79b0d60fd1778
X-Google-Attributes: gid10cc67,public
X-Google-ArrivalTime: 2003-03-23 23:15:01 PST
From: "Ed Mulroy [TeamB]" <ed@mulroy.org>
Newsgroups: borland.public.cppbuilder.nativeapi
References: <3e7bd0f7@newsgroups.borland.com> <3e7bda80@newsgroups.borland.com> <3e7c4c63@newsgroups.borland.com>
Subject: Re: Getting Drive for an given directory
Date: Sat, 22 Mar 2003 12:04:00 -0500
Lines: 40
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1106
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106
NNTP-Posting-Host: 24.74.175.102
Message-ID: <3e7c9790$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1048352656 24.74.175.102 (22 Mar 2003 09:04:16 -0800)
X-Authenticated-User: edmulroy
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-03!sn-xit-01!sn-xit-09!supernews.com!iad-peer.news.verio.net!news.verio.net!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mail