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.
34 #include <proto/xfdmaster.h>
36 #include <proto/cybergraphics.h>
37 #include <cybergraphx/cybergraphics.h>
42 struct FileInfoBlock __aligned fileinfo
;
43 int a
,success
,win
,err
,addicon
= 0;
44 char dirname
[FILEBUF_SIZE
],new_directory
[256];
47 win
=data_active_window
;
48 if (/*(dopus_curwin[win] == dopus_specialwin[win]) ||*/ (dopus_curwin
[win
]->directory
[0] == 0)) return;
49 dirname
[0]=new_directory
[0]=0;
54 if (!rexx_args
[0][a
] || rexx_args
[0][a
]=='/' || rexx_args
[0][a
]==':') break;
56 if (!rexx_args
[0][a
]) {
57 if (!(isvalidwindow(data_active_window
))) return;
58 strcpy(new_directory
,str_pathbuffer
[data_active_window
]);
59 TackOn(new_directory
,rexx_args
[0],256);
60 if (rexx_args
[1][0] && (rexx_args
[1][0] == '1')) addicon
= 1;
63 strcpy(new_directory
,rexx_args
[0]);
67 else if (status_iconified
) {
68 if (!(status_flags
&STATUS_ISINBUTTONS
) ||
69 (!(getdummypath(new_directory
,STR_ENTER_DIRECTORY_NAME
)))) return;
73 if (!(isvalidwindow(data_active_window
))) return;
74 strcpy(new_directory
,str_pathbuffer
[data_active_window
]);
76 if (!(whatsit(globstring
[STR_ENTER_DIRECTORY_NAME
],
77 config
->iconflags
&ICONFLAG_MAKEDIRICON
? FILEBUF_SIZE
-7 : FILEBUF_SIZE
-2,
83 for (a
=0;dirname
[a
];a
++) {
84 if (dirname
[a
]=='/' || dirname
[a
]==':') {
93 TackOn(new_directory
,dirname
,256);
96 if (!(lock
=CreateDir(new_directory
))) {
97 doerror((err
=IoErr()));
98 if (rexx
|| (a
=checkerror(globstring
[STR_CREATING_DIRECTORY
],
99 BaseName(new_directory
),-err
))==3) {
106 Examine(lock
,&fileinfo
);
110 addfile(dopus_curwin
[win
],win
,fileinfo
.fib_FileName
,-1,
111 fileinfo
.fib_DirEntryType
,&fileinfo
.fib_Date
,
112 NULL
,fileinfo
.fib_Protection
,0,TRUE
,NULL
,NULL
,
113 fileinfo
.fib_OwnerUID
,fileinfo
.fib_OwnerGID
);
115 update_buffer_stamp(win
,1);
119 if ((config
->iconflags
&ICONFLAG_MAKEDIRICON
) || addicon
) {
120 strcat(new_directory
,".info");
121 if ((iconwrite(ICONTYPE_DRAWER
,new_directory
))==1 &&
122 (lockandexamine(new_directory
,&fileinfo
))) {
124 addfile(dopus_curwin
[win
],win
,fileinfo
.fib_FileName
,
125 fileinfo
.fib_Size
,fileinfo
.fib_DirEntryType
,&fileinfo
.fib_Date
,
126 fileinfo
.fib_Comment
,fileinfo
.fib_Protection
,0,TRUE
,NULL
,NULL
,
127 fileinfo
.fib_OwnerUID
,fileinfo
.fib_OwnerGID
);
129 update_buffer_stamp(win
,1);
136 if (success
) dostatustext(globstring
[STR_DIRECTORY_CREATED
]);
139 int iconwrite(type
,name
)
144 struct DiskObject
*diskobj
;
145 char namebuf
[256],*ptr
,*originalicon
,sourcebuf
[256];
146 struct dopusfiletype
*ftype
;
148 if (!IconBase
) return(0);
150 strcpy(namebuf
,name
);
151 if ((ptr
=strstri(namebuf
,".info"))) *ptr
=0;
153 if (type
==ICONTYPE_DRAWER
) originalicon
=config
->drawericon
;
154 else if (type
==ICONTYPE_TRASH
) originalicon
=NULL
;
156 ftype
=checkfiletype(namebuf
,-2,0);
157 if (ftype
&& ftype
->iconpath
) originalicon
=ftype
->iconpath
;
158 else if (type
==ICONTYPE_TOOL
) originalicon
=config
->toolicon
;
159 else originalicon
=config
->projecticon
;
163 strcpy(sourcebuf
,originalicon
);
164 if (!(strstri(sourcebuf
,".info"))) strcat(sourcebuf
,".info");
168 if (originalicon
&& originalicon
[0] && (CheckExist(sourcebuf
,NULL
)<0)) {
169 if ((copyicon(originalicon
,namebuf
,&err
))>0) return(1);
172 if (/*system_version2 &&*/ (diskobj
=GetDefDiskObject(type
+2))) {
173 if (diskobj
->do_Type
==WBPROJECT
&& config
->defaulttool
[0]) {
174 ptr
=diskobj
->do_DefaultTool
;
175 diskobj
->do_DefaultTool
=config
->defaulttool
;
178 suc
=PutDiskObject(namebuf
,diskobj
);
179 if (ptr
) diskobj
->do_DefaultTool
=ptr
;
180 FreeDiskObject(diskobj
);
185 if (type
==ICONTYPE_PROJECT
)
186 icontable
[ICONTYPE_PROJECT
]->do_DefaultTool
=config
->defaulttool
;
187 if (PutDiskObject(namebuf
,icontable
[type
])) return(1);
191 if ((suc
=checkerror(globstring
[STR_ADDING_ICON
],BaseName(namebuf
),err
))==3)
193 if (suc
==0 || suc
==2) return(0);
197 int copyicon(srce
,dest
,err
)
202 struct DiskObject
*diskobj
;
203 char /*buf[256],*/buf1
[256],*ptr
;
206 if ((ptr
=strstri(buf1
,".info"))) *ptr
=0;
208 if ((diskobj
=GetDiskObject(buf1
))) {
209 suc
=PutDiskObject(dest
,diskobj
);
210 FreeDiskObject(diskobj
);
211 if (!suc
|| CheckExist(dest
,NULL
)>=0) *err
=IoErr();
214 // StrCombine(buf,dest,".info",256);
215 // suc=copyfile(srce,buf,err,/*-1,*/NULL,0);
216 SetIoErr(ERROR_OBJECT_NOT_FOUND
);
227 if ((a
=strlen(name
))<6) return(NULL
);
228 if (Stricmp(&name
[a
-5],".info")==0) return(&name
[a
-5]);
232 char *getarexxpath(rexx
,win
,num
,argnum
)
233 int rexx
,win
,num
,argnum
;
235 struct FileInfoBlock __aligned fblock
;
240 if (!rexx
|| !rexx_argcount
) return(str_pathbuffer
[win
]);
241 if ((strchr(rexx_args
[argnum
],':') || strchr(rexx_args
[argnum
],'/')) &&
242 (a
=CheckExist(rexx_args
[argnum
],&b
))) {
244 save
=main_proc
->pr_WindowPtr
;
245 main_proc
->pr_WindowPtr
=(APTR
)-1;
246 dos_global_entry
.subtype
=0;
247 if (lockandexamine(rexx_args
[argnum
],&fblock
)) {
248 dos_global_entry
.protection
=fblock
.fib_Protection
;
249 dos_global_entry
.comment
=dos_copy_comment
;
250 strcpy(dos_copy_comment
,fblock
.fib_Comment
);
251 dos_global_entry
.dispstr
=NULL
;
252 getprot(dos_global_entry
.protection
,dos_global_entry
.protbuf
);
253 CopyMem(&fblock
.fib_Date
,&dos_global_entry
.date
,sizeof(struct DateStamp
));
254 seedate(&dos_global_entry
.date
,dos_global_entry
.datebuf
,1);
255 dos_global_entry
.selected
=0;
257 main_proc
->pr_WindowPtr
=save
;
258 ptr
=BaseName(rexx_args
[argnum
]);
259 strcpy(dos_global_entry
.name
,ptr
);
260 if (ptr
>rexx_args
[argnum
]) {
262 strcpy(rexx_pathbuffer
[win
],rexx_args
[argnum
]);
263 TackOn(rexx_pathbuffer
[win
],NULL
,256);
265 else rexx_pathbuffer
[win
][argnum
]=0;
266 dos_global_entry
.last
=dos_global_entry
.next
=NULL
;
267 dos_global_entry
.type
=a
;
268 dos_global_entry
.size
=b
;
269 func_single_entry
=&dos_global_entry
;
270 removeargstring(argnum
);
271 return(rexx_pathbuffer
[win
]);
274 strcpy(rexx_pathbuffer
[win
],rexx_args
[argnum
]);
275 TackOn(rexx_pathbuffer
[win
],NULL
,256);
276 removeargstring(argnum
);
277 return(rexx_pathbuffer
[win
]);
280 return(str_pathbuffer
[win
]);
283 int readfile(name
,buf
,size
)
288 int retval
/*loadpp*/ = 0;
291 if ((in=ppLoadData(name,DECR_POINTER,MEMF_CLEAR,buf,size,NULL))) {
292 if (in==PP_OPENERR || in==PP_READERR) return(-1);
293 if (in==PP_NOMEMORY) return(-2);
299 if (CheckExist(name
,size
)>=0 || !(in
=Open(name
,MODE_OLDFILE
))) return(-1);
300 if ((*buf
=AllocVec(*size
,MEMF_ANY
)))
307 struct xfdBufferInfo
*xfdbi
;
309 if ((xfdbi
= xfdAllocObject(XFDOBJ_BUFFERINFO
)))
311 xfdbi
->xfdbi_SourceBuffer
= *buf
;
312 xfdbi
->xfdbi_SourceBufLen
= *size
;
313 // xfdbi->xfdbi_Flags = XFDFB_RECOGEXTERN;
314 if (xfdRecogBuffer(xfdbi
))
316 xfdbi
->xfdbi_TargetBufMemType
= MEMF_ANY
;
317 if (xfdDecrunchBuffer(xfdbi
))
319 FreeVec(xfdbi
->xfdbi_SourceBuffer
);
320 // *size = xfdbi->xfdbi_TargetBufLen;
321 *size
= xfdbi
->xfdbi_TargetBufSaveLen
;
322 if ((*buf
= AllocVec(*size
, MEMF_ANY
))) CopyMem(xfdbi
->xfdbi_TargetBuffer
,*buf
,*size
);
323 else *buf
= xfdbi
->xfdbi_TargetBuffer
;
327 xfdFreeObject(xfdbi
);
334 //D(bug("readfile() ends\n");Delay(50);)
338 int getnewprot(old
,new,mask
)
343 if (!mask
) return(new);
347 if (old
&(1<<a
)) val
|=(1<<a
);
349 else if (new&(1<<a
)) val
|=(1<<a
);
360 if (flag
&(1<<a
)) return(a
);
365 int checkscreenmode(mode
)
368 DisplayInfoHandle
*handle
;
369 struct DimensionInfo
*dimension
;
373 if (mode
==MODE_WORKBENCHUSE
|| mode
==MODE_WORKBENCHCLONE
|| mode
==MODE_PUBLICSCREEN
)
375 /* if (!system_version2) {
376 if (mode==HIRES_KEY || mode==HIRESLACE_KEY) return(mode);
377 return(MODE_WORKBENCHCLONE);
379 if (!(handle
=FindDisplayInfo(mode
)) ||
380 !(GetDisplayInfoData(handle
,buf
,256,DTAG_DISP
,0)) ||
381 ((struct DisplayInfo
*)buf
)->NotAvailable
)
382 return(MODE_WORKBENCHCLONE
);
385 if (IsCyberModeID(mode
))
387 if (GetCyberIDAttr(CYBRIDATTR_WIDTH
,mode
) >= 640) return (mode
);
390 flags
=((struct DisplayInfo
*)buf
)->PropertyFlags
;
391 if (flags
&DIPF_IS_DUALPF
|| flags
&DIPF_IS_PF2PRI
|| flags
&DIPF_IS_HAM
||
392 !(GetDisplayInfoData(handle
,buf
,256,DTAG_DIMS
,0)))
393 return(MODE_WORKBENCHCLONE
);
394 dimension
=(struct DimensionInfo
*)buf
;
395 if (mode
&HIRES_KEY
|| mode
&HIRESLACE_KEY
) minw
=640;
397 minw
=dimension
->MinRasterWidth
;
398 if (minw
<160) minw
*=10;
400 defw
=(dimension
->TxtOScan
.MaxX
-dimension
->TxtOScan
.MinX
)+1;
401 if ((minw
<640 || defw
<640) && dimension
->MaxDepth
>=5)
402 return(MODE_WORKBENCHCLONE
);
406 void doarrowgadgets(gad
,dir
)
424 screen_pens
[config
->arrowfg
].pen
,
425 screen_pens
[config
->arrowbg
].pen
,dir
);
430 void makermbgad(rmbgad
,gad
,high
)
431 struct RMBGadget
*rmbgad
;
435 rmbgad
->x
=gad
->LeftEdge
;
436 rmbgad
->y
=gad
->TopEdge
;
437 rmbgad
->w
=gad
->Width
;
438 rmbgad
->h
=gad
->Height
;
439 if (high
&& gad
->GadgetRender
) {
440 rmbgad
->flags
|=RGF_ALTBORD
;
441 rmbgad
->high_bord
[0]=gad
->GadgetRender
;
442 rmbgad
->high_bord
[1]=gad
->SelectRender
;
444 else rmbgad
->flags
&=~RGF_ALTBORD
;
447 void dolittlegads(gad
,txt
,num
)
453 struct TextFont
*font
;
455 if (status_iconified
|| !Window
) return;
458 SetFont(main_rp
,scr_font
[FONT_GENERAL
]);
459 for (a
=0;a
<num
;a
++) {
460 do3dbox(main_rp
,gad
->LeftEdge
+2,gad
->TopEdge
+1,gad
->Width
-4,gad
->Height
-2);
461 SetAPen(main_rp
,screen_pens
[config
->littlegadbg
].pen
);
462 rectfill(main_rp
,gad
->LeftEdge
+2,gad
->TopEdge
+1,gad
->Width
-4,gad
->Height
-2);
463 SetAPen(main_rp
,screen_pens
[config
->littlegadfg
].pen
);
464 SetBPen(main_rp
,screen_pens
[config
->littlegadbg
].pen
);
465 y
=gad
->TopEdge
+1+(((gad
->Height
-2)-scr_font
[FONT_GENERAL
]->tf_YSize
)/2);
466 if (y
<gad
->TopEdge
+1) y
=gad
->TopEdge
+1;
467 y
+=scr_font
[FONT_GENERAL
]->tf_Baseline
;
468 Move(main_rp
,gad
->LeftEdge
+((gad
->Width
-scr_font
[FONT_GENERAL
]->tf_XSize
)/2),y
);
469 Text(main_rp
,&txt
[a
],1);
470 RefreshGList(gad
,Window
,NULL
,1);
471 if (!(gad
=gad
->NextGadget
)) break;
473 SetFont(main_rp
,font
);
476 void rectfill(r
,x
,y
,w
,h
)
480 if (w
<0 || h
<0) return;
481 RectFill(r
,x
,y
,x
+w
-1,y
+h
-1);
484 int isvalidwindow(win
)
487 if (!str_pathbuffer
[win
]) return(0);
488 if (dopus_curwin
[win
]->total
>0 && dopus_curwin
[win
]->firstentry
->type
==ENTRY_CUSTOM
)
493 int _isdigit (unsigned char c
)
495 return locale
?IsDigit(locale
,c
):isdigit(c
);
498 int _isxdigit (unsigned char c
)
500 return locale
?IsXDigit(locale
,c
):isxdigit(c
);
503 int _isprint (unsigned char c
)
505 return locale
?IsPrint(locale
,c
):isprint(c
);
508 int _isspace (unsigned char c
)
510 return locale
?IsSpace(locale
,c
):isspace(c
);
513 int _isupper (unsigned char c
)
515 return locale
?IsUpper(locale
,c
):isupper(c
);
518 int _ispunct (unsigned char c
)
520 return locale
?IsPunct(locale
,c
):ispunct(c
);