Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1 | daniel-mar | 1 | unit ZMCompat19; |
2 | |||
3 | (* |
||
4 | ZMCompat19.pas - Types and utility functions required for some compilers |
||
5 | TZipMaster19 VCL by Chris Vleghert and Eric W. Engler |
||
6 | v1.9 |
||
7 | Copyright (C) 2009 Russell Peters |
||
8 | |||
9 | |||
10 | This library is free software; you can redistribute it and/or |
||
11 | modify it under the terms of the GNU Lesser General Public |
||
12 | License as published by the Free Software Foundation; either |
||
13 | version 2.1 of the License, or (at your option) any later version. |
||
14 | |||
15 | This library is distributed in the hope that it will be useful, |
||
16 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
||
18 | Lesser General Public License (licence.txt) for more details. |
||
19 | |||
20 | You should have received a copy of the GNU Lesser General Public |
||
21 | License along with this library; if not, write to the Free Software |
||
22 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
||
23 | |||
24 | contact: problems AT delphizip DOT org |
||
25 | updates: http://www.delphizip.org |
||
26 | |||
27 | modified 2009-12-26 |
||
28 | ---------------------------------------------------------------------------*) |
||
29 | |||
30 | interface |
||
31 | |||
32 | {$I '.\ZipVers19.inc'} |
||
33 | |||
34 | {$ifndef UNICODE} |
||
35 | type |
||
36 | TCharSet = set of AnsiChar; |
||
37 | {$IFDEF VERpre6} |
||
38 | //type |
||
39 | // UTF8String = type String; |
||
40 | PCardinal = ^Cardinal; |
||
41 | |||
42 | procedure FreeAndNil(var obj); |
||
43 | procedure RaiseLastOSError; |
||
44 | function ExcludeTrailingBackslash(const fn: string): string; |
||
45 | function IncludeTrailingBackslash(const fn: string): string; |
||
46 | function AnsiSameText(const s1, s2: string): boolean; |
||
47 | {$ENDIF} |
||
48 | |||
49 | function CharInSet(C: AnsiChar; const CharSet: TCharSet): Boolean; |
||
50 | |||
51 | |||
52 | {$ENDIF} |
||
53 | |||
54 | |||
55 | function MakeStrP(const str: String): PAnsiChar; |
||
56 | |||
57 | implementation |
||
58 | |||
59 | uses |
||
60 | SysUtils; |
||
61 | |||
62 | {$ifndef UNICODE} |
||
63 | function CharInSet(C: AnsiChar; const CharSet: TCharSet): Boolean;// overload; |
||
64 | begin |
||
65 | Result := c in CharSet; |
||
66 | end; |
||
67 | |||
68 | {$IFDEF VERpre6} |
||
69 | procedure FreeAndNil(var obj); |
||
70 | var |
||
71 | o: TObject; |
||
72 | begin |
||
73 | o := TObject(obj); |
||
74 | TObject(obj) := NIL; |
||
75 | if assigned(o) then |
||
76 | o.Free; |
||
77 | end; |
||
78 | {$ENDIF} |
||
79 | |||
80 | {$IFDEF VERpre6} |
||
81 | procedure RaiseLastOSError; |
||
82 | begin |
||
83 | RaiseLastWin32Error; |
||
84 | end; |
||
85 | {$ENDIF} |
||
86 | |||
87 | {$IFDEF VERpre6} |
||
88 | function ExcludeTrailingBackslash(const fn: string): string; |
||
89 | begin |
||
90 | if fn[Length(fn)] = '\' then |
||
91 | Result := Copy(fn, 1, Length(fn) - 1) |
||
92 | else |
||
93 | Result := fn; |
||
94 | end; |
||
95 | {$ENDIF} |
||
96 | |||
97 | {$IFDEF VERpre6} |
||
98 | function IncludeTrailingBackslash(const fn: string): string; |
||
99 | begin |
||
100 | if fn[Length(fn)] <> '\' then |
||
101 | Result := fn + '\' |
||
102 | else |
||
103 | Result := fn; |
||
104 | end; |
||
105 | {$ENDIF} |
||
106 | |||
107 | |||
108 | {$IFDEF VERpre6} |
||
109 | function AnsiSameText(const s1, s2: string): boolean; |
||
110 | begin |
||
111 | Result := CompareText(s1, s2) = 0; |
||
112 | end; |
||
113 | {$ENDIF} |
||
114 | |||
115 | {$endif} |
||
116 | |||
117 | function MakeStrP(const str: String): PAnsiChar; |
||
118 | {$ifdef UNICODE} |
||
119 | var |
||
120 | StrA: AnsiString; |
||
121 | {$endif} |
||
122 | begin |
||
123 | {$ifdef UNICODE} |
||
124 | StrA := AnsiString(str); |
||
125 | Result := AnsiStrAlloc(Length(StrA) + 1); |
||
126 | StrPLCopy(Result, StrA, Length(StrA) + 1); |
||
127 | {$else} |
||
128 | Result := StrAlloc(Length(Str) + 1); |
||
129 | StrPLCopy(Result, Str, Length(Str) + 1); |
||
130 | {$endif} |
||
131 | end; |
||
132 | |||
133 | end. |