00001
00002 #include <stdlib.h>
00003 #include <string.h>
00004 #include <direct.h>
00005
00006 char globalWorkingDir[_MAX_PATH];
00007
00008 const char *GetMPKWorkingDirectory()
00009 {
00010 return globalWorkingDir;
00011 }
00012
00013 void SetMPKWorkingDirectory(const char *path)
00014 {
00015 strncpy(globalWorkingDir, path, _MAX_PATH);
00016 }
00017
00018
00019 void GetAbsoluteFileName(char *fullname, int len, const char *path, const char *filename)
00020 {
00021
00022 if (strchr(filename, ':'))
00023 {
00024 strncpy(fullname, filename, len);
00025 return;
00026 }
00027 else if ((filename[0]=='\\') && (filename[1]=='\\'))
00028 {
00029 }
00030
00031
00032 if ((path == NULL) && (filename == NULL))
00033 {
00034 fullname[0] = '\0';
00035 return;
00036 }
00037 else if (path == NULL)
00038 {
00039 strncpy(fullname, filename, len);
00040 return;
00041 }
00042 else if (filename == NULL)
00043 {
00044 strncpy(fullname, path, len);
00045 return;
00046 }
00047
00048
00049
00050 if ((*fullname == '\\') || (*fullname == '/'))
00051 {
00052 if (strchr(path, ':') == NULL)
00053 {
00054
00055 fullname[0] = _getdrive() + 'A';
00056 fullname[1] = '\0';
00057 }
00058 else
00059 {
00060
00061 strncpy(fullname, path, 2);
00062 fullname[1] = '\0';
00063 }
00064 strncat(fullname, filename, len-strlen(fullname));
00065 return;
00066 }
00067
00068
00069 strncpy(fullname, path, len);
00070 strncat(fullname, filename, len-strlen(fullname));
00071 }