bool VFSHandle_ZIP::Createfile(char *filename, bool recurse) { LocalFileHeader *lfh = new LocalFileHeader; FileHeader *fh = new FileHeader; time_t t; time(&t); tm *time = localtime(&t); time->tm_sec/=2; time->tm_mon+=1; time->tm_year-=80; #define MAKETIME(h,m,s) h<<11 | m<<5 | s #define MAKEDATE(d,m,y) y<<9 | m<<5 | d // Make a Local File Header lfh->version = 20; lfh->general_flags = 2; lfh->compression_method = 8; lfh->time = MAKETIME(time->tm_hour,time->tm_min,time->tm_sec); lfh->date = MAKEDATE(time->tm_mday,time->tm_mon,time->tm_year); lfh->crc32 = 0; lfh->comp_size = 0; lfh->uncomp_size = 0; lfh->filename_length = (unsigned short)strlen(filename); lfh->extrafield_length = (unsigned short)strlen(""); lfh->filename = new char[strlen(filename)+1]; lfh->extrafield = ""; lfh->file_data_offset = 0; strcpy(lfh->filename,filename); // Make a File Header for the CD fh->version = lfh->version; fh->version_extract = lfh->version; fh->general_flags = lfh->general_flags; fh->compression_method = lfh->compression_method; fh->time = lfh->time; fh->date = lfh->date; fh->crc32 = lfh->crc32; fh->comp_size = lfh->comp_size; fh->uncomp_size = lfh->uncomp_size; fh->filename_length = lfh->filename_length; fh->extrafield_length = lfh->extrafield_length; fh->file_comment_length = 0; fh->disk_number_start = 0; fh->internal_file_attrib = 0; fh->external_file_attrib = 0; fh->relative_offset_lfh = 0; fh->filename = new char[strlen(filename)+1]; fh->extrafield = ""; fh->file_comment = ""; m_cd.size += (FH_LEN + (unsigned int)strlen(filename)); strcpy(fh->filename,filename); m_lfh.push_back(lfh); m_fh.push_back(fh); m_cd.total_entries++; m_cd.total_entries_disk++; delete[] m_file; m_file = new char[strlen(filename)+1]; strcpy(m_file,filename); return true; }
time_t gettime(void) { return MAKETIME(asm_readcmos(CMOS_REG_HOUR),asm_readcmos(CMOS_REG_MIN),asm_readcmos(CMOS_REG_SEC)); }