source: trunk/dll/dirs.c@ 843

Last change on this file since 843 was 843, checked in by Steven Levine, 18 years ago

Revert to standard APIs where large file support not required by ticket #41

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 2.1 KB
Line 
1
2/***********************************************************************
3
4 $Id: dirs.c 843 2007-09-23 22:46:47Z stevenhl $
5
6 Copyright (c) 1993-98 M. Kimes
7 Copyright (c) 2003, 2007 Steven H.Levine
8
9 Directory manipulation
10
11 20 Aug 07 GKY Move #pragma alloc_text to end for OpenWatcom compat
12
13***********************************************************************/
14
15#define INCL_WIN
16#define INCL_WINERRORS
17#define INCL_DOS
18#define INCL_DOSERRORS
19#define INCL_LONGLONG
20
21#include <os2.h>
22#include <stdlib.h>
23#include <stdio.h>
24#include <stdarg.h>
25#include <string.h>
26#include <ctype.h>
27#include "fm3dll.h"
28
29APIRET save_dir2(CHAR * curdir)
30{
31
32 CHAR *env = getenv("FM3INI");
33
34 if (env && *env) {
35 strncpy(curdir, env, CCHMAXPATH);
36 curdir[CCHMAXPATH - 1] = 0;
37 if (IsValidDir(curdir))
38 return 0;
39 else {
40 env = strrchr(curdir, '\\');
41 if (env) {
42 *env = 0;
43 if (IsValidDir(curdir))
44 return 0;
45 }
46 }
47 }
48 return save_dir(curdir);
49}
50
51APIRET save_dir(CHAR * curdir)
52{
53
54 APIRET ret;
55 ULONG curdirlen, curdrive, drivemap;
56
57 *curdir = 0;
58 ret = DosQCurDisk(&curdrive, &drivemap);
59 curdirlen = CCHMAXPATH - 4; /* NOTE!!!!!!!!! */
60 ret += DosQCurDir(curdrive, &curdir[3], &curdirlen);
61 *curdir = (CHAR) ('@' + (INT) curdrive);
62 curdir[1] = ':';
63 curdir[2] = '\\';
64 return ret;
65}
66
67APIRET switch_to(CHAR * s)
68{
69
70 APIRET ret;
71 FILESTATUS3 fsa;
72 CHAR path[CCHMAXPATH + 1], *p;
73
74 strcpy(path, s);
75 while (*path) {
76 ret = DosQueryPathInfo(path, FIL_STANDARD, &fsa, sizeof(fsa));
77 if (ret || !(fsa.attrFile & FILE_DIRECTORY)) {
78 p = strrchr(path, '\\');
79 if (p)
80 *p = 0;
81 else {
82 strcpy(path, s);
83 break;
84 }
85 }
86 else
87 break;
88 }
89 if (isalpha(*path) && path[1] == ':') {
90
91 ULONG curdrive, drivemap;
92
93 if (!DosQCurDisk(&curdrive, &drivemap)) {
94 if ((CHAR) ((CHAR) curdrive + '@') != (CHAR) toupper(*HomePath) &&
95 (CHAR) ((CHAR) curdrive + '@') != (CHAR) toupper(*path))
96 DosChDir("\\");
97 }
98 ret = DosSelectDisk(toupper(*path) - '@');
99 return (ret) ? ret : DosChDir(path);
100 }
101 return DosChDir(path);
102}
103
104#pragma alloc_text(MISC9,save_dir,save_dir2,switch_to)
Note: See TracBrowser for help on using the repository browser.