source: trunk/dll/dirs.c@ 841

Last change on this file since 841 was 841, checked in by Gregg Young, 18 years ago

This implements large file support; The wrappers to allow WARP3 compatibility are not done so this will not run on Warp3or Warp 4 pre fixpack 12(?)

  • 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 841 2007-09-23 16:27:51Z gyoung $
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 FILESTATUS3L fsa;
72 CHAR path[CCHMAXPATH + 1], *p;
73
74 strcpy(path, s);
75 while (*path) {
76 ret = DosQueryPathInfo(path, FIL_STANDARDL, &fsa,
77 (ULONG) sizeof(FILESTATUS3L));
78 if (ret || !(fsa.attrFile & FILE_DIRECTORY)) {
79 p = strrchr(path, '\\');
80 if (p)
81 *p = 0;
82 else {
83 strcpy(path, s);
84 break;
85 }
86 }
87 else
88 break;
89 }
90 if (isalpha(*path) && path[1] == ':') {
91
92 ULONG curdrive, drivemap;
93
94 if (!DosQCurDisk(&curdrive, &drivemap)) {
95 if ((CHAR) ((CHAR) curdrive + '@') != (CHAR) toupper(*HomePath) &&
96 (CHAR) ((CHAR) curdrive + '@') != (CHAR) toupper(*path))
97 DosChDir("\\");
98 }
99 ret = DosSelectDisk(toupper(*path) - '@');
100 return (ret) ? ret : DosChDir(path);
101 }
102 return DosChDir(path);
103}
104
105#pragma alloc_text(MISC9,save_dir,save_dir2,switch_to)
Note: See TracBrowser for help on using the repository browser.