Skip to content

Commit

Permalink
fixup deprecation of externalAttributes
Browse files Browse the repository at this point in the history
- directly access private member internally
- only deprecate the property
  • Loading branch information
MartinNowak committed Dec 14, 2013
1 parent 6e7b79b commit f1261a2
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions std/zip.d
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,7 @@ class ArchiveMember
private ushort _madeVersion = 20;
private ushort _extractVersion = 20;
private ushort _diskNumber;
// should be private when deprecation done
deprecated("Please use fileAttributes instead.") uint externalAttributes;
private uint _externalAttributes;
private DosFileTime _time;

ushort flags; /// Read/Write: normally set to 0
Expand All @@ -95,6 +94,10 @@ class ArchiveMember
@property ushort extractVersion() { return _extractVersion; } /// Read Only
@property uint crc32() { return _crc32; } /// Read Only: cyclic redundancy check (CRC) value

/// OS specific file attributes
deprecated("Please use fileAttributes instead.")
@property ref inout(uint) externalAttributes() inout { return _externalAttributes; }

/// Read Only: size of data of member in compressed form.
@property uint compressedSize() { return _compressedSize; }

Expand Down Expand Up @@ -127,13 +130,13 @@ class ArchiveMember
{
version (Posix)
{
externalAttributes = (attr & 0xFFFF) << 16;
_externalAttributes = (attr & 0xFFFF) << 16;
_madeVersion &= 0x00FF;
_madeVersion |= 0x0300; // attributes are in UNIX format
}
else version (Windows)
{
externalAttributes = attr;
_externalAttributes = attr;
_madeVersion &= 0x00FF; // attributes are in MS-DOS and OS/2 format
}
else
Expand All @@ -146,7 +149,7 @@ class ArchiveMember
{
auto am = new ArchiveMember();
am.fileAttributes = octal!100644;
assert(am.externalAttributes == octal!100644 << 16);
assert(am._externalAttributes == octal!100644 << 16);
assert((am._madeVersion & 0xFF00) == 0x0300);
}

Expand All @@ -162,13 +165,13 @@ class ArchiveMember
version (Posix)
{
if ((_madeVersion & 0xFF00) == 0x0300)
return externalAttributes >> 16;
return _externalAttributes >> 16;
return 0;
}
else version (Windows)
{
if ((_madeVersion & 0xFF00) == 0x0000)
return externalAttributes;
return _externalAttributes;
return 0;
}
else
Expand Down Expand Up @@ -427,7 +430,7 @@ class ZipArchive
putUshort(i + 32, cast(ushort)de.comment.length);
putUshort(i + 34, de.diskNumber);
putUshort(i + 36, de.internalAttributes);
putUint (i + 38, de.externalAttributes);
putUint (i + 38, de._externalAttributes);
putUint (i + 42, de.offset);
i += 46;

Expand Down Expand Up @@ -554,7 +557,7 @@ class ZipArchive
commentlen = getUshort(i + 32);
de._diskNumber = getUshort(i + 34);
de.internalAttributes = getUshort(i + 36);
de.externalAttributes = getUint(i + 38);
de._externalAttributes = getUint(i + 38);
de.offset = getUint(i + 42);
i += 46;

Expand Down

0 comments on commit f1261a2

Please sign in to comment.