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.
37 void seedate(ds
,date
,pad
)
42 char timebuf
[16],datebuf
[16]/*,buf[40]*/;
43 struct DOpusDateTime dt
;
45 copy_datestamp(ds
,&dt
.dat_Stamp
);
46 initdatetime(&dt
,datebuf
,timebuf
,1);
48 lsprintf(date
,"%s %s",datebuf
,timebuf
);
49 //D(bug("date: %s, time: %s\n",datebuf,timebuf));
51 strncpy(buf,datebuf,9);
58 if (config->dateformat&DATE_12HOUR) lsprintf(date,"%19s",buf);
59 else lsprintf(date,"%18s",buf);
61 else strcpy(date,buf);
65 int setdate(name
,date
)
67 struct DateStamp
*date
;
69 /* char __aligned bstrname[FILEBUF_SIZE+4];
70 struct MsgPort *handler;
75 int rc
=/*0*/SetFileDate(name
,date
);
77 wsave=main_proc->pr_WindowPtr;
78 main_proc->pr_WindowPtr=(APTR)-1;
80 if (handler=(struct MsgPort *)DeviceProc(name)) {
81 if (lock=Lock(name,ACCESS_READ)) {
82 parentlock=ParentDir(lock);
85 strcpy(&bstrname[1],FilePart(name));
86 bstrname[0]=strlen(&bstrname[1]);
89 arg[1]=(IPTR)parentlock;
90 arg[2]=(IPTR)MKBADDR(bstrname);
92 rc=SendPacket(handler,ACTION_SET_DATE,arg,4);
97 main_proc->pr_WindowPtr=wsave;
107 static char buf
[256];
109 if (win
<0 || status_iconified
) return;
110 if (!dopus_curwin
[win
]->firstentry
||
111 (dopus_curwin
[win
]->firstentry
->type
!=ENTRY_DEVICE
&&
112 dopus_curwin
[win
]->firstentry
->type
!=ENTRY_CUSTOM
)) {
113 if (str_pathbuffer
[win
][0]==0) {
114 if (win
==data_active_window
)
115 SetAPen(main_rp
,screen_pens
[config
->disknameselbg
].pen
);
116 else SetAPen(main_rp
,screen_pens
[config
->disknamebg
].pen
);
118 scrdata_diskname_xpos
[win
]+2,scrdata_diskname_ypos
,
119 scrdata_diskname_width
[win
],scrdata_diskname_height
-2);
120 SetAPen(main_rp
,screen_pens
[1].pen
);
124 if (dopus_curwin
[win
]->flags
& DWF_ARCHIVE
)
126 if (dopus_curwin
[win
]->arcname
)
130 //D(bug("path: %s",dopus_curwin[win]->arcname));
131 c
= strstr(dopus_curwin
[win
]->directory
,FilePart(dopus_curwin
[win
]->arcname
));
132 if (c
) for (a
= 0; c
&& (*c
!= '/') && (a
< 31); c
++) dopus_curwin
[win
]->diskname
[a
++] = *c
;
133 dopus_curwin
[win
]->diskname
[a
] = 0;
138 strcpy(buf
,str_pathbuffer
[win
]);
139 dopus_curwin
[win
]->diskname
[0]=0;
140 main_proc
->pr_WindowPtr
=(APTR
)-1;
141 if (!(a
=getroot(buf
,NULL
))) {
142 strcpy(dopus_curwin
[win
]->diskname
,globstring
[STR_DIR_NOT_AVAILABLE_TITLE
]);
144 dopus_curwin
[win
]->disktot
= i64_atoi( "-1" );
145 dopus_curwin
[win
]->diskfree
= i64_atoi( "-1" );
146 dopus_curwin
[win
]->diskblock
= -1;
148 dopus_curwin
[win
]->disktot
=dopus_curwin
[win
]->diskfree
=dopus_curwin
[win
]->diskblock
=-1;
151 if (config
->errorflags
&ERROR_ENABLE_DOS
) main_proc
->pr_WindowPtr
=(APTR
)Window
;
154 strcpy(dopus_curwin
[win
]->diskname
,buf
);
156 strcpy(dopus_curwin
[win
]->volumename
,buf
);
158 dopus_curwin
[win
]->diskfree
=bytes(str_pathbuffer
[win
],&tot
,&bl
);
159 dopus_curwin
[win
]->disktot
=tot
;
160 dopus_curwin
[win
]->diskblock
=bl
;
161 if (a
==ID_WRITE_PROTECTED
) dopus_curwin
[win
]->flags
|=DWF_READONLY
;
162 else dopus_curwin
[win
]->flags
&=~DWF_READONLY
;
163 if (config
->errorflags
&ERROR_ENABLE_DOS
) main_proc
->pr_WindowPtr
=(APTR
)Window
;
169 void displayname(win
,clear
)
173 bigint free
, tot
, temp1
;
177 int b
,x
,nn
=0,len
,len2
,len3
,x1
,cx1
,cx2
;
178 static char buf
[30],buf2
[80],buf3
[20];
181 if (status_iconified
|| win
<0) return;
182 if (str_pathbuffer
[win
][0]==0) {
186 temp1
= i64_atoi( "-1" );
188 if ( i64_cmp( dopus_curwin
[win
]->disktot
, temp1
) != I64_EQUAL
&&
190 if (dopus_curwin
[win
]->disktot
!=-1 &&
192 (!dopus_curwin
[win
]->firstentry
|| dopus_curwin
[win
]->firstentry
->type
!=ENTRY_DEVICE
)) nn
=2;
196 free
=dopus_curwin
[win
]->diskfree
; tot
=dopus_curwin
[win
]->disktot
;
197 SetDrMd(main_rp
,JAM2
);
199 StrCombine(buf2
,dopus_curwin
[win
]->diskname
,str_space_string
,80);
200 SetFont(main_rp
,scr_font
[FONT_NAMES
]);
203 x1
=dotextlength(main_rp
,buf2
,&len
,scrdata_diskname_width
[win
]-4);
206 temp1
= i64_atoi( "-1" );
207 if (!nn
&& ( i64_cmp( tot
, temp1
) == I64_GREATER
)) {
211 if (config
->showfree
&SHOWFREE_BYTES
|| config
->showfree
==0) {
215 i64_itoa( free
, buf1
, 30 );
216 if (dopus_curwin
[win
]->flags
&DWF_READONLY
)
217 lsprintf(buf
," (%s)",buf1
);
218 else lsprintf(buf
," %s",buf1
);
220 if (dopus_curwin
[win
]->flags
&DWF_READONLY
) sprintf(buf
," (%qd)",free
);
221 else sprintf(buf
," %qd",free
);
224 else if (config
->showfree
&SHOWFREE_KILO
) {
225 getsizestring(buf
,free
);
226 if (dopus_curwin
[win
]->flags
&DWF_READONLY
)
230 lsprintf(buf1
,"(%s)",buf
);
234 else if (config
->showfree
&SHOWFREE_BLOCKS
) {
235 if (dopus_curwin
[win
]->flags
&DWF_READONLY
)
236 lsprintf(buf
," (%ld)",dopus_curwin
[win
]->diskblock
);
237 else lsprintf(buf
," %ld",dopus_curwin
[win
]->diskblock
);
239 else if (config
->showfree
&SHOWFREE_PERCENT
) {
241 temp1
= i64_atoi( "0" );
243 if ( i64_cmp( tot
, temp1
) == I64_EQUAL
) b
=100;
245 pct
=free
.lo
; pct
*=100; // HUX ??
246 b
=(int)(pct
/(double)tot
.lo
); // HUX ??
252 b
=(int)(pct
/(double)tot
);
256 if (dopus_curwin
[win
]->flags
&DWF_READONLY
)
257 lsprintf(buf
," (%ld%%)",b
);
258 else lsprintf(buf
," %ld%%",b
);
260 StrCombine(buf3
,buf
,str_space_string
,14);
261 len2
=12; len3
=strlen(buf
);
263 x
=dotextlength(main_rp
,buf3
,&len2
,scrdata_diskname_width
[win
]-x1
-4);
264 if (len2
>=len3
|| (--len
)==0) break;
265 len2
=12; x1
=dotextlength(main_rp
,buf2
,&len
,scrdata_diskname_width
[win
]-4);
267 strncpy(buf3
,str_space_string
,13);
268 strcpy(&buf3
[len2
-len3
],buf
);
274 if (win
==data_active_window
)
275 SetAPen(main_rp
,screen_pens
[config
->disknameselbg
].pen
);
276 else SetAPen(main_rp
,screen_pens
[config
->disknamebg
].pen
);
278 scrdata_diskname_xpos
[win
]+2,
279 scrdata_diskname_ypos
,
280 scrdata_diskname_width
[win
],
281 scrdata_diskname_height
-2);
285 if (win
==data_active_window
) {
286 SetAPen(main_rp
,screen_pens
[config
->disknameselfg
].pen
);
287 SetBPen(main_rp
,screen_pens
[config
->disknameselbg
].pen
);
290 SetAPen(main_rp
,screen_pens
[config
->disknamefg
].pen
);
291 SetBPen(main_rp
,screen_pens
[config
->disknamebg
].pen
);
295 scrdata_diskname_xpos
[win
]+4,
296 scrdata_diskname_ypos
+scr_font
[FONT_NAMES
]->tf_Baseline
);
297 Text(main_rp
,buf2
,len
);
301 x1
=(scrdata_diskname_xpos
[win
]+scrdata_diskname_width
[win
])-x
;
302 if (x1
<scrdata_diskname_xpos
[win
]+2) x1
=scrdata_diskname_xpos
[win
]+2;
304 Move(main_rp
,x1
,scrdata_diskname_ypos
+scr_font
[FONT_NAMES
]->tf_Baseline
);
305 Text(main_rp
,buf3
,len2
);
307 else cx2
=scrdata_diskname_xpos
[win
]+scrdata_diskname_width
[win
]+1;
308 if (!clear
&& cx1
<=cx2
) {
309 SetAPen(main_rp
,main_rp
->BgPen
);
310 RectFill(main_rp
,cx1
,scrdata_diskname_ypos
,cx2
,scrdata_diskname_height
+scrdata_diskname_ypos
-3);
312 SetFont(main_rp
,scr_font
[FONT_GENERAL
]);
316 void relabel_disk(rexx
,path
)
320 // struct MsgPort *port;
321 char oldname
[36],name
[36]/*,*bstr*/;
326 strcpy(buf
,rexx
?rexx_args
[0]:path
);
327 D(bug("relabel(%ld,%s)\n",rexx
,buf
));
328 if (!(getroot(buf
,NULL
))) {
333 // if (!(port=(struct MsgPort *) DeviceProc(buf))) return;
336 strcpy(name
,buf
); strcpy(oldname
,name
);
338 if (!(whatsit(globstring
[STR_ENTER_NEW_DISK_NAME
],30,name
,NULL
))) return;
340 else strcpy(name
,rexx_args
[1]);
342 if (name
[strlen(name
)-1] == ':') name
[strlen(name
)-1] = 0;
345 D(bug("Relabel(%s,%s)\n",buf
,name
));
346 if (! Relabel(buf
,name
)) doerror(-1);
349 bstr=(char *) AllocMem(a+2,MEMF_CLEAR))
352 arg=(IPTR)MKBADDR(bstr);
353 if (!(SendPacket(port,ACTION_RENAME_DISK,&arg,1))) doerror(-1);
355 else if ((!status_iconified
) && (dopus_curwin
[data_active_window
] != dopus_specialwin
[data_active_window
])) {
356 if ((Strnicmp(str_pathbuffer
[data_active_window
],oldname
,strlen(oldname
)))==0 &&
357 str_pathbuffer
[data_active_window
][strlen(oldname
)]==':') {
359 StrConcat(buf
,&str_pathbuffer
[data_active_window
][strlen(oldname
)],256);
360 strcpy(str_pathbuffer
[data_active_window
],buf
);
361 checkdir(str_pathbuffer
[data_active_window
],&path_strgadget
[data_active_window
]);
362 strcpy(dopus_curwin
[data_active_window
]->directory
,str_pathbuffer
[data_active_window
]);
364 seename(data_active_window
);
366 // FreeMem(bstr,a+2);
371 struct DateStamp
*ds
;
373 struct InfoData __aligned info
;
375 struct FileLock
*lock2
;
377 struct DeviceList
*dl
;
380 if (!(lock1
=Lock(name
,ACCESS_READ
))) return(0);
381 lock2
=(struct FileLock
*) BADDR(lock1
);
382 for (a
=0;a
<FILEBUF_SIZE
;a
++) name
[a
]=0;
383 dl
=(struct DeviceList
*)BADDR(lock2
->fl_Volume
);
384 p
=(char *) BADDR(dl
->dl_Name
);
386 if (p
) LStrnCpy(name
,AROS_BSTR_ADDR(p
),AROS_BSTR_strlen(p
));
388 if (p
) LStrnCpy(name
,p
+1,*p
);
390 if (ds
) CopyMem((char *)&dl
->dl_VolumeDate
,(char *)ds
,sizeof(struct DateStamp
));
393 return(info
.id_DiskState
);
396 BPTR
getrootlock(lock1
)
401 while ((lock2
=ParentDir(lock1
))) {
408 void strtostamp(date
,time
,ds
)
410 struct DateStamp
*ds
;
412 struct DOpusDateTime datetime
;
414 datetime.dat_Stamp.ds_Days = 0;
415 datetime.dat_Stamp.ds_Minute = 0;
416 datetime.dat_Stamp.ds_Tick = 0;
418 datetime
.dat_Format
=dateformat(config
->dateformat
);
419 datetime
.dat_Flags
=0/*DDTF_SUBST|DDTF_CUSTOM*/;
420 datetime
.dat_StrDate
=date
;
421 datetime
.dat_StrTime
=time
;
422 // datetime.custom_months=date_months;
423 // datetime.custom_shortmonths=date_shortmonths;
424 // datetime.custom_weekdays=date_weekdays;
425 // datetime.custom_shortweekdays=date_shortweekdays;
426 // datetime.custom_special_days=date_special;
427 // StrToStamp(&datetime);
428 StrToDate((struct DateTime
*)&datetime
);
429 // D(bug("strtostamp(%s,%s)=%ld\n",date,time,StrToDate((struct DateTime *)&datetime)));
430 copy_datestamp(&datetime
.dat_Stamp
,ds
);