GetProjectDir

int GetProjectDir (char directoryName[]);

Purpose

Gets the name of the directory that contains the currently loaded project file.

You can use GetProjectDir when you distribute a project and its related files to multiple users who might place the files in a different directory on each computer. If your program needs to access a file that is in the same directory as the project, you can use GetProjectDir and MakePathname to construct the full pathname.

In a stand-alone executable, the function obtains the directory containing the executable file.

/* Get the name of the directory that contains myfile. */
char *fileName;
char projectDir[MAX_PATHNAME_LEN];
char fullPath[MAX_PATHNAME_LEN];
fileName = "myfile";
if (GetProjectDir (projectDir) < 0)

FmtOut ("Project is untitled\n");

else

MakePathname (projectDir, fileName, fullPath);

Parameters

Output
Name Type Description
directoryName string The buffer in which the project directory name is returned.

directoryName must be at least MAX_PATHNAME_LEN bytes long.

Return Value

Name Type Description
result integer The result of the call.

Code Description
0 Success.
-1 Current project has no pathname; the project is untitled.
-2 There is no current project.