2 Copyright © 1995-2019, The AROS Development Team. All rights reserved.
7 #include "icon_intern.h"
9 /*****************************************************************************
12 #include <proto/icon.h>
14 AROS_LH2(UBYTE
*, BumpRevision
,
17 AROS_LHA(UBYTE
*, newname
, A0
),
18 AROS_LHA(UBYTE
*, oldname
, A1
),
21 struct IconBase
*, IconBase
, 18, Icon
)
24 Computes the right copy revision for a file name.
27 newname - a buffer for the new string. Should be at least 31 bytes.
28 oldname - the old name to be revisioned.
31 pointer to the supplied buffer.o
43 *****************************************************************************/
46 UBYTE tempstr
[50]; /* A string to hold the new string, this one is big
47 enough to hold any new possible string. Then we
48 truncate this one into the newstr */
50 BOOL founddigit
= FALSE
;
56 if (!strncmp (oldname
, "copy_", 5))
58 /* Just a usual filename */
59 strcpy (tempstr
, "copy_of_");
60 strcpy (tempstr
+ 8, oldname
);
64 /* Possible double or multiple-copy */
65 if (!strncmp (oldname
,"copy_of_", 8)) /* Is this a first copy ?*/
68 strcpy (tempstr
, "copy_2_of_");
69 strcat (tempstr
, oldname
+ 8);
73 /* Possible multiple copy */
74 /* Step past "copy_" */
77 /* Convert number from text into integer */
78 while (c
= *oldnameptr
, ((c
>='0') && (c
<='9')) )
80 /* Get the number of this copy. (copy_xxx_of_) */
82 copy_number
+= (c
- 0x30);
87 /* Valid ? (multiple copy or rubbish ?) */
89 if (((!strncmp(oldnameptr
,"_of_",4)) && founddigit
))
91 /* convert back from num to text, but first increase copycount */
103 /* Rubbish, add copy_of_ and move into tempstr */
104 strcpy (tempstr
, "copy_of_");
105 strcpy (tempstr
+ 8, oldname
);
110 /* Truncate tempstr into newstr */
111 CopyMem(tempstr
, newname
, 30);
113 /* Be sure that it is nullterminated */
114 newname
[30] = 0; /* The 31th character */