static void AddModule(char *module) { char *projFile; char *srcFile; char *hdrFile; autoList_t *lines; char *line; uint index; errorCase(!lineExp("<__09AZaz>", module)); projFile = GetProjFile(); srcFile = changeExt(module, "cpp"); hdrFile = changeExt(module, "h"); errorCase(existPath(srcFile)); errorCase(existPath(hdrFile)); lines = readLines(projFile); index = FindIndex(lines, 0, "<\t\t >Name=\"ソース ファイル\""); index = FindIndex(lines, index + 1, "<\t\t >>"); insertElement(lines, index + 1, (uint)xcout("<File RelativePath=\".\\%s\"></File>", srcFile)); index = FindIndex(lines, 0, "<\t\t >Name=\"ヘッダー ファイル\""); index = FindIndex(lines, index + 1, "<\t\t >>"); insertElement(lines, index + 1, (uint)xcout("<File RelativePath=\".\\%s\"></File>", hdrFile)); writeLines_xx(projFile, lines); addLine2File_cx("all.h", xcout("#include \"%s\"", hdrFile)); writeOneLine(srcFile, "#include \"all.h\""); createFile(hdrFile); // "all" ならここで all.h は空のファイルになる。 memFree(srcFile); memFree(hdrFile); }
static generic_string addExt(HWND textCtrl, HWND typeCtrl) { TCHAR fn[MAX_PATH]; ::GetWindowText(textCtrl, fn, MAX_PATH); int i = ::SendMessage(typeCtrl, CB_GETCURSEL, 0, 0); int cbTextLen = ::SendMessage(typeCtrl, CB_GETLBTEXTLEN, i, 0); TCHAR * ext = new TCHAR[cbTextLen + 1]; ::SendMessage(typeCtrl, CB_GETLBTEXT, i, (LPARAM)ext); TCHAR *pExt = get1stExt(ext); if (*fn != '\0') { generic_string fnExt = changeExt(fn, pExt); ::SetWindowText(textCtrl, fnExt.c_str()); } generic_string returnExt = pExt; delete[] ext; return returnExt; };
static BOOL CALLBACK fileDlgProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { switch (message) { case WM_COMMAND : { switch (wParam) { case IDOK : { HWND fnControl = ::GetDlgItem(hwnd, FileDialog::_dialogFileBoxId); TCHAR fn[MAX_PATH]; ::GetWindowText(fnControl, fn, MAX_PATH); // Check condition to have the compability of default behaviour if (*fn == '\0') return oldProc(hwnd, message, wParam, lParam); else if (::PathIsDirectory(fn)) return oldProc(hwnd, message, wParam, lParam); // Process if (currentExt != TEXT("")) { generic_string fnExt = changeExt(fn, currentExt, false); ::SetWindowText(fnControl, fnExt.c_str()); } return oldProc(hwnd, message, wParam, lParam); } default : break; } } } return oldProc(hwnd, message, wParam, lParam); };
void main(){ int input; int output; long int offset; char buffer[512]; long int tileCount; int row; int bytesRead; char fileName[35]; char outputName[35]; srcin: printf("File to extract from:"); getString(30, fileName); addExt(fileName, "nes"); input = openFile(fileName, 'r'); if(input == -1){ printf("Couldn't open %s!\n\n", fileName); goto srcin; } destin: printf("Bitmap to output to:"); getString(30, outputName); changeExt(outputName, "bmp"); output = openFile(outputName, 't'); if(output == -1){ printf("Couldn't open %s!\n\n", outputName); goto destin; } printf("\nEnter starting address:"); offset=hexInput(); printf("\nExtract how many tiles?"); tileCount=hexInput(); prepBMP(output,tileCount); row = (tileCount - 1) / 32 + 1; lseek(input,offset + (long) (row-1) * 512, 0); bytesRead= _read(input,buffer,512); if (bytesRead / 16 < ((tileCount%32==0)? 32 : tileCount%32)){ printf("File not long enough!"); exit(1); } convert(buffer,output,(tileCount%32==0) ? 32 : tileCount%32,row); row--; while(row > 0){ if(row%32==0) printf("\n%li tiles left to extract....",(long) row*32); lseek(input,offset + (long) (row-1) * 512, 0); bytesRead= _read(input,buffer,512); convert(buffer,output,32,row); row--; } close(input); close(output); printf("\nDone!"); }