Encode the contents of the file with the supplied path, from 7-Bit ASCII to Base64. The encoded data is then in a hzChain instance.
Return Type | Function name | Arguments |
---|---|---|
hzEcode | Base64Encode | (hzChain&,const char*,const char*,) |
Declared in file: hzCodec.h
Defined in file : hzCodec.cpp
Function Logic:
Function body:
hzEcode Base64Encode (hzChain& Encoded, const char* dir, const char* fname) { // Category: Codec // // Encode the contents of the file with the supplied path, from 7-Bit ASCII to Base64. The encoded data is then in a hzChain instance. // // Arguments: 1) Encoded The chain to contain the encoded data // 2) dir The directory of the file containing the 7-Bit ASCII data to encode // 3) fname The file name within the directory // // Returns: E_ARGUMENT If either the directory or filename are not supplied // E_NOTFOUND If the filepath specified does not exist as a directory entry of any kind // E_TYPE If the filepath names a directory entry that is not a file // E_NODATA If the filepath is a file but empty // E_OPENFAIL If the file specified could not be opened for reading // E_OK If the input stream was opened and the content encoded _hzfunc("Base64Encode(file)") ; std::ifstream is ; hzChain Z ; hzString Path ; hzEcode rc ; if (!dir || !dir[0]) return hzerr(E_ARGUMENT, "No directory supplied") ; if (!fname || !fname[0]) return hzerr(E_ARGUMENT, "No filename supplied") ; Path = dir ; Path += "/" ; Path += fname ; rc = OpenInputStrm(is, *Path) ; if (rc == E_OK) { Z << is ; is.close() ; Base64Encode(Encoded, Z) ; } return rc ; }