BOOL SetupReadFile( LPSTR pszdir, LPSTR pszfile, LPSTR pszCommentToEOL, FILE **ppf ) { char path[DB_MAX_PATH_LENGTH]; assert(!Frb.fOpen); assert(Frb.pf == NULL); assert(Frb.pszFile == NULL); Frb.fMakefile = strcmp(pszCommentToEOL, "#") == 0; Frb.DateTime.value = 0; strcpy(path, pszdir); if (Frb.pfrbNext != NULL) { // if a nested open LPSTR p; if (Frb.fMakefile && !IsFullPath(pszfile)) { // nmake handles relative includes in makefiles by // attempting to locate the file relative to each makefile // in the complete include chain. FILEREADBUF *pfrb; for (pfrb = Frb.pfrbNext; pfrb != NULL; pfrb = pfrb->pfrbNext) { assert(pfrb->pszFile != NULL); strcpy(path, pfrb->pszFile); p = FindLastPathSeparator(path); if (p != NULL) { *p = '\0'; } if (ProbeFile(path, pszfile) != -1) { break; } } if (pfrb == NULL) { // Unable to find file anywhere along path. return FALSE; } } else { p = FindLastPathSeparator(path); if (p != NULL) { *p = '\0'; } } } if (!MyOpenFile(path, pszfile, "rb", ppf, TRUE)) { *ppf = NULL; return(FALSE); } if (Frb.fMakefile) { Frb.DateTime = (*pDateTimeFile)(path, pszfile); } Frb.cLine = 0; Frb.cNull = 0; Frb.cbTotal = 0; Frb.pf = *ppf; Frb.fEof = FALSE; Frb.pszCommentToEOL = pszCommentToEOL; Frb.cbCommentToEOL = strlen(pszCommentToEOL); if (fseek(Frb.pf, 0L, SEEK_END) != -1) { Frb.cbFile = ftell(Frb.pf); if (fseek(Frb.pf, 0L, SEEK_SET) == -1) { Frb.cbFile = 0; } } else { Frb.cbFile = 0; } Frb.cbBuffer = BigBufSize; if (Frb.pfrbNext != NULL) { if (Frb.cbBuffer > Frb.cbFile + 1) { Frb.cbBuffer = Frb.cbFile + 1; } AllocMem(Frb.cbBuffer, (VOID **) &Frb.pbBuffer, MT_IOBUFFER); } else { Frb.pbBuffer = BigBuf; } if (!ReadBuf(Frb.pf)) { fclose(Frb.pf); Frb.pf = *ppf = NULL; if (Frb.pfrbNext != NULL) { FreeMem((VOID **) &Frb.pbBuffer, MT_IOBUFFER); } return(FALSE); // zero byte file } if (path[0] != '\0') { strcat(path, PATH_SEPARATOR); } strcat(path, pszfile); MakeString(&Frb.pszFile, path, TRUE, MT_FRBSTRING); Frb.fOpen = TRUE; if (Frb.fMakefile && DEBUG_4) { BuildError( "Opening file: cbFile=%lu cbBuf=%lu\n", Frb.cbTotal, Frb.cbBuffer); } return(TRUE); }
int main(int argc, char* argv[]) { // const int RED = 100; // const int GREEN = 200; // /// 100; // // int a = 0; // const int * pInt = &a; // //*pInt = 200; // pInt = &argc; // // Fun1("Hello"); // // Fun2(a); // // // // MovieData data; // // ShowData(data); // // //data // char* pData = (char*)Fun4(); // pData[0] = '1'; int a = 10; int b = 20; int& refA = a; //printf("%d %d", a, refA); exch(a, b); T1 tObj; T1 tObj2; //this == 对象的首地址 // 某个存储单元 = this tObj.SetData(100); tObj2.SetData(10); //tObj.Show(); //链式 // T1& tObj2 = tObj; // // tObj.GetSelf().Show(); //other:1 //show:1 //show:2 //other:2 //show:3 puts("Show()"); //tObj2.Show(); MyOpenFile("test.exe"); //Fun5(1, 2); // Add(1, 2); // Add(1.f, 2.f); int n; //Add(1, n); // Add(1, (const char*)"h"); Test t; t.~Test(); // Test* pTest = new Test; // // //pTest->Test::Test(); // // delete pTest; // pTest = NULL; new int[2]; Test* pObjAry = new Test[2]; delete [] pObjAry; return 0; }