🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.cppbuilder.nativeapi
8 messages
8 total messages Started by Jeff Douglass Tue, 25 Mar 2003 15:44
Another application's path question.
#17462
Author: Jeff Douglass
Date: Tue, 25 Mar 2003 15:44
28 lines
2280 bytes
I have asked a bunch of directory and path questions over the past few days
and have received all the answers I need. After further thinking I have come
to conclustion that maby the question I should have asked was this since
almost everyone should have an answer for it since it must me common. I have
an app that REQUIRES a certain directory structure to work. Up untill now I
have hard coded the directory structure using #defines and actually
delivered this directory structure along with the app's installation media.
For example; the app requred the follow dir structure

c:\Visinet ---- this is the app's main/master directory
c:\Visinet\GUI --- location of the gui
c:\Visinet\Drivers --- location of driver exes required by app
c:\Visinet\FEP ---- location of the app's server
c:\Visinet\Runtim --- location of the app's data base files

also, there are required directories within some of these directories.

Overall question. I now want to allow the user to be able to control the
app's master directory. ie change c:\visinet to say d:\nms

What is the standard/best way for the app to handle this? I have implemented
a mechanism using the info received from the recent postings but am not very
pleased with my implementation so I figured I would ask everyone else how
they handle this. Sample code or links would be great.

Thanks for any and all suggestions.

Jeff
Re: Another application's path question.
#17466
Author: Holy Punk
Date: Tue, 25 Mar 2003 13:59
8 lines
1328 bytes
"Jeff Douglass" <.> wrote in message
news:3e808a8e$1@newsgroups.borland.com...
> is the basic id. In general, what is the best way for an app to use, as a
> reference for all app specific directory requirments, the actual location
of
> the app. Hope this clears it up.

As you mentioned using path to main exe is fine. Also, you can use Registry.
Re: Another application's path question.
#17463
Author: Rodolfo Frino - Stargate Softwar...
Date: Tue, 25 Mar 2003 15:56
36 lines
2011 bytes
I'm not sure if this is what you're looking for

String ComposeParentPath(String Drive, String Dir)
{
  return Drive + ":\\" + Dir + "\\";
}

   // Initially
   String ParentPath1 = ComposeParentPath("C", "Visinet");

   // User will change it
   String ParentPath2 = ComposeParentPath("D", "nms");

    // an example using the Parent Path
    if (CopyFile((ParentPath2 + "file1.bmp").c_str(),
                         (ParentPath2 + "file2.bmp").c_str(), false))
    {
        ShowMessage("Copied");
    }
    else
    {
        ShowMessage("CopyFile failed");
    }

Rodolfo


> Overall question. I now want to allow the user to be able to control the
> app's master directory. ie change c:\visinet to say d:\nms
>
> What is the standard/best way for the app to handle this? I have
implemented
> a mechanism using the info received from the recent postings but am not
very
> pleased with my implementation so I figured I would ask everyone else how
> they handle this. Sample code or links would be great.
Re: Another application's path question.
#17465
Author: Jeff Douglass
Date: Tue, 25 Mar 2003 16:50
15 lines
1876 bytes
Actually here is what I am looking for. The first step of my product's
installation is to copy the master specified directory from the installation
media to the computer's c drive. This is the visinet dir and it contains all
the other required directories. Up to now, the user had to keep this
structure intact and was required to install the GUI, step 2, into the GUI
dir located in the master dir. Now I want the user to be able to change the
name and drive of the master dir. This dir must still contain the original
structure but can have a different name and location. The app then on start
up would could use the Application->ExeName to figure out what the master
dir is and use this as a reference to all other required directories. That
is the basic id. In general, what is the best way for an app to use, as a
reference for all app specific directory requirments, the actual location of
the app. Hope this clears it up.

Thanks again.
Re: Another application's path question.
#17468
Author: Remy Lebeau (TeamB)
Date: Tue, 25 Mar 2003 18:12
20 lines
1696 bytes
"Jeff Douglass" <.> wrote in message
news:3e807afd$1@newsgroups.borland.com...
> Overall question. I now want to allow the user to be
> able to control the app's master directory. ie change
> c:\visinet to say d:\nms
>
> What is the standard/best way for the app to handle this?

Extract the application's installation folder (or assign whatever folder you
want) and then just append the other paths to it when needed, ie:

    AnsiString RootFolder = ExtractFilePath(Application->ExeName);
    AnsiString GUIFolder = RootFolder + "GUI";
    AnsiString DriversFolder = RootFolder + "Drivers";
    AnsiString FEPFolder = RootFolder + "FEP"
    AnsiString RuntimeFolder = RootFolder + "Runtim";


Gambit
Re: Another application's path question.
#17469
Author: Remy Lebeau (TeamB)
Date: Tue, 25 Mar 2003 18:13
11 lines
1356 bytes
See my other reply for a sample of exactly that.


Gambit

"Jeff Douglass" <.> wrote in message
news:3e808a8e$1@newsgroups.borland.com...
> The app then on start up would could use the
> Application->ExeName to figure out what the master
> dir is and use this as a reference to all other required
> directories.
Re: Another application's path question.
#17376
Author: Rodolfo Frino - Stargate Softwar...
Date: Tue, 25 Mar 2003 22:38
26 lines
2028 bytes
For what you explain I assume that the user will select both the drive
and the installation directory. Then you want the same directory structure
as the default structure below the InstallationDirectory. If this is the
case,
you can use this approach:

1) First Create the Installation Directory as required
   // maybe from a TDirectoryListBox and a TDriveComboBox

    //String InstallationDir = ComposeInstallationDir("D", "nms");
    //String InstallationDir =whatever function you write;
    //String InstallationDir = "C:\\Visinet\\";  //InstallationDir has to
have this format
    String InstallationDir = "D:\\mns\\";         //another example

 2) Then create the directory structure below the Installation directory
    CreateDir(InstallationDir);
    CreateDir(InstallationDir + "Drivers");
    CreateDir(InstallationDir + "FEP");
    CreateDir(InstallationDir + "GUI");
    CreateDir(InstallationDir + "Runtim");

Note that CreateDir() is the VCL function and not the API which has 2
arguments

Rodolfo
Re: Another application's path question.
#17403
Author: Jim Dodd
Date: Wed, 26 Mar 2003 14:56
46 lines
2992 bytes
Another useful VCL/CLX function is ForceDirectories() which will attempt
to create all the directories in a path.

The Help says:

bool __fastcall ForceDirectories(AnsiString Dir);
ForceDirectories creates a new directory as specified in Dir, which must 
be a fully-qualified path name. If the directories given in the path do 
not yet exist, ForceDirectories attempts to create them.

Regards,

Jim Dodd
Onset Computer Corp.

Jeff Douglass wrote:
> I have asked a bunch of directory and path questions over the past few days
> and have received all the answers I need. After further thinking I have come
> to conclustion that maby the question I should have asked was this since
> almost everyone should have an answer for it since it must me common. I have
> an app that REQUIRES a certain directory structure to work. Up untill now I
> have hard coded the directory structure using #defines and actually
> delivered this directory structure along with the app's installation media.
> For example; the app requred the follow dir structure
> 
> c:\Visinet ---- this is the app's main/master directory
> c:\Visinet\GUI --- location of the gui
> c:\Visinet\Drivers --- location of driver exes required by app
> c:\Visinet\FEP ---- location of the app's server
> c:\Visinet\Runtim --- location of the app's data base files
> 
> also, there are required directories within some of these directories.
> 
> Overall question. I now want to allow the user to be able to control the
> app's master directory. ie change c:\visinet to say d:\nms
> 
> What is the standard/best way for the app to handle this? I have implemented
> a mechanism using the info received from the recent postings but am not very
> pleased with my implementation so I figured I would ask everyone else how
> they handle this. Sample code or links would be great.
> 
> Thanks for any and all suggestions.
> 
> Jeff
> 
> 
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads