MCPcopy Create free account
hub / github.com/CyanogenMod/android_frameworks_base / initNew

Method initNew

tools/aapt/ZipEntry.cpp:112–136  ·  view source on GitHub ↗

* Initialize a new entry. Pass in the file name and an optional comment. * * Initializes the CDE and the LFH. */

Source from the content-addressed store, hash-verified

110 * Initializes the CDE and the LFH.
111 */
112void ZipEntry::initNew(const char* fileName, const char* comment)
113{
114 assert(fileName != NULL && *fileName != '\0'); // name required
115
116 /* most fields are properly initialized by constructor */
117 mCDE.mVersionMadeBy = kDefaultMadeBy;
118 mCDE.mVersionToExtract = kDefaultVersion;
119 mCDE.mCompressionMethod = kCompressStored;
120 mCDE.mFileNameLength = strlen(fileName);
121 if (comment != NULL)
122 mCDE.mFileCommentLength = strlen(comment);
123 mCDE.mExternalAttrs = 0x81b60020; // matches what WinZip does
124
125 if (mCDE.mFileNameLength > 0) {
126 mCDE.mFileName = new unsigned char[mCDE.mFileNameLength+1];
127 strcpy((char*) mCDE.mFileName, fileName);
128 }
129 if (mCDE.mFileCommentLength > 0) {
130 /* TODO: stop assuming null-terminated ASCII here? */
131 mCDE.mFileComment = new unsigned char[mCDE.mFileCommentLength+1];
132 strcpy((char*) mCDE.mFileComment, comment);
133 }
134
135 copyCDEtoLFH();
136}
137
138/*
139 * Initialize a new entry, starting with the ZipEntry from a different

Callers 1

addCommonMethod · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected