4 Original GPL release version 4.12
5 Copyright 1993-2000 Jonathan Potter
7 This program is free software; you can redistribute it and/or
8 modify it under the terms of the GNU General Public License
9 as published by the Free Software Foundation; either version 2
10 of the License, or (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 All users of Directory Opus 4 (including versions distributed
22 under the GPL) are entitled to upgrade to the latest version of
23 Directory Opus version 5 at a reduced price. Please see
24 http://www.gpsoft.com.au for more information.
26 The release of Directory Opus 4 under the GPL in NO WAY affects
27 the existing commercial status of Directory Opus 5.
33 void do_path_completion(win
,qual
)
37 struct FileInfoBlock __aligned finfo
;
38 char path
[256],match
[FILEBUF_SIZE
],*ptr
;
40 struct complete_entry
*entry
,*curentry
,*addpos
;
43 strcpy(path
,str_pathbuffer
[win
]);
45 if (a
>0 && (path
[a
-1]=='/' || path
[a
-1]==':')) match
[0]=0;
46 else if (ptr
=BaseName(path
)) {
47 LStrnCpy(match
,ptr
,FILEBUF_SIZE
-1);
48 match
[FILEBUF_SIZE
-1]=0;
56 if (LStrCmp(completion
[win
].path
,path
)!=0) new=1;
57 else if (LStrCmp(completion
[win
].match
,match
)!=0) {
58 entry
=completion
[win
].firstentry
;
60 if (Stricmp(match
,entry
->name
)==0) break;
64 else if (entry
!=completion
[win
].currententry
) {
65 completion
[win
].currententry
=entry
;
71 strcpy(completion
[win
].match
,match
);
72 strcpy(completion
[win
].path
,path
);
73 LFreeRemember(&completion
[win
].memory
);
74 completion
[win
].firstentry
=NULL
;
75 completion
[win
].currententry
=NULL
;
78 if (lock
=Lock(path
,ACCESS_READ
)) {
80 if (finfo
.fib_DirEntryType
>0) {
81 while (ExNext(lock
,&finfo
)) {
82 if (status_haveaborted
) break;
83 if (finfo
.fib_DirEntryType
>0 &&
84 (!match
[0] || LStrnCmpI(finfo
.fib_FileName
,match
,strlen(match
))==0)) {
85 if (entry
=LAllocRemember(&completion
[win
].memory
,
86 sizeof(struct complete_entry
),MEMF_CLEAR
)) {
87 strcpy(entry
->name
,finfo
.fib_FileName
);
88 addpos
=completion
[win
].firstentry
;
92 if (Stricmp(addpos
->name
,entry
->name
)>0) break;
97 entry
->last
=addpos
->last
;
99 if (entry
->last
) entry
->last
->next
=entry
;
100 if (addpos
==completion
[win
].firstentry
)
101 completion
[win
].firstentry
=entry
;
105 curentry
->next
=entry
;
106 entry
->last
=curentry
;
108 else completion
[win
].firstentry
=entry
;
119 if (completion
[win
].currententry
) {
120 if (qual
&IEQUALIFIER_ANYSHIFT
)
121 completion
[win
].currententry
=completion
[win
].currententry
->last
;
122 else completion
[win
].currententry
=completion
[win
].currententry
->next
;
125 if (!completion
[win
].currententry
) {
126 if (qual
&IEQUALIFIER_ANYSHIFT
) {
127 entry
=completion
[win
].firstentry
;
128 while (entry
&& entry
->next
) entry
=entry
->next
;
129 completion
[win
].currententry
=entry
;
131 else completion
[win
].currententry
=completion
[win
].firstentry
;
132 if (!completion
[win
].currententry
) {
134 ActivateStrGad(&path_strgadget
[win
],Window
);
139 strcpy(str_pathbuffer
[win
],path
);
140 TackOn(str_pathbuffer
[win
],completion
[win
].currententry
->name
,256);
141 RefreshStrGad(&path_strgadget
[win
],Window
);
142 ActivateStrGad(&path_strgadget
[win
],Window
);