-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlfnapi.cpp
More file actions
174 lines (147 loc) · 3.53 KB
/
Copy pathlfnapi.cpp
File metadata and controls
174 lines (147 loc) · 3.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
#include "lfn.cpp"
int switch_uninstall;
void(__cdecl __interrupt __far *int21h)();
void PrintHelp(void)
{
#ifdef LANG_EN
printf("This is Odi's API for long file names %s\n",LFN_VER);
printf("Copyright (C) 2000 Ortwin Glueck\nThis is free software under GPL. See the readme file for details.\n\n");
printf("Usage: lcopy [drive:][path]sourcefile [drive:][path][destinationfile][/?]\n\n");
printf("Copy selected files.\n");
printf("Switches:\n");
printf("/c\tDisable cache\n");
#endif
#ifdef LANG_DE
printf("Odi's API fr lange Dateinamen %s\n",LFN_VER);
printf("Copyright (C) 2000 Ortwin Glck\nDies ist freie Software unter der GPL. Siehe readme Datei fr Details.\n\n");
printf("LCOPY [Laufwerk:][Pfad]Quelldatei [Laufwerk:][Pfad][Zieldatei][/?]\n\n");
printf("Kopiert Dateien.\n");
printf("Optionen:\n");
printf("/c\tCache abschalten\n");
#endif
exit(0);
}
void ParseParams(char *arg)
{
int i;
for (i=0;arg[i]=='/';i++)
{
i++;
switch (toupper(arg[i]))
{
case 'H':
case '?': PrintHelp();
break;
case 'U': switch_uninstall=1;
break;
default:
#ifdef LANG_EN
printf("Invalid switch.\n");
#endif
#ifdef LANG_DE
printf("Unbekannte Option.\n");
#endif
exit(1);
break;
}
}
}
int GetVolumeInformation(char __far *pszFS, unsigned int size, char __far *pszRoot, word *flags)
{
int drv,err;
struct DPB Disk;
drv=drive_of_path(pszRoot);
printf("DEBUG:%u (%u)\n",drv,size);
makeDPB(drv,Disk);
err = 0;
switch (Disk.fat_type)
{
case NO:
return 1;
break;
case FAT12:
case FAT16:
if (size>3)
strcpy(pszFS,"FAT");
*flags=0x4000;
break;
case FAT32:
if (size>5)
strncpy(pszFS,"FAT32",size);
*flags=0x4006;
break;
case CD:
if (size>4)
strncpy(pszFS,"CDFS",size);
if (Disk.cdfs==CD_JOLIET) {
*flags=0x4006;
}
else {
*flags=0x4000;
}
break;
}
return err;
}
void (__interrupt __far __cdecl Dispatcher)( unsigned _es, unsigned _ds,
unsigned _di, unsigned _si,
unsigned _bp, unsigned _sp,
unsigned _bx, unsigned _dx,
unsigned _cx, unsigned _ax,
unsigned _ip, unsigned _cs,
unsigned flags)
{
#define PTR(seg,ofs) (void*)((((long)seg) << 16) | ((long)ofs))
char __far *pszFS, *pszRoot;
int err=0;
word bits;
_enable();
switch (_ax)
{
case 0x71A0:
pszFS = (char*) PTR(_es,_di);
pszRoot = (char*) PTR(_ds,_dx);
err=GetVolumeInformation(pszFS,_cx,pszRoot, &bits);
_bx=bits;
_cx=0x00ff;
_dx=0x0104;
break;
default:
_chain_intr(int21h);
break;
}
if (err) {
flags|=1; //set carry flag
_ax=err;
}
else {
flags&=0xfffe; //clear carry flag
}
}
void Map21hFunctions()
{
int21h = _dos_getvect(0x21);
_dos_setvect(0x21, (void (__interrupt __far __cdecl *)(void))&Dispatcher);
}
void main(int argc, char *argv[], char *envp)
{
int i;
switch_uninstall=0;
for (i=1;i<argc;i++)
{
if (argv[i][0]=='/')
ParseParams(argv[i]);
}
/* check if already installed! */
Map21hFunctions();
initCache();
//_heapmin();
int rSS, rSP,paragraphs;
_asm {
mov [rSS],ss
mov [rSP],sp
}
paragraphs = rSS+rSP/16;
printf("reserved Paragraphs: %u", paragraphs);
_dos_keep(0,paragraphs);
}