📄 avc_e00read.c
字号:
**********************************************************************/static int _AVCE00ReadBuildSqueleton(AVCE00ReadPtr psInfo, char **papszCoverDir){ int iSect, iTable, numTables, iFile, nLen; char **papszTables, **papszFiles, szCWD[75]="", *pcTmp; char *pszEXPPath=NULL; int nCoverPrecision = AVC_DEFAULT_PREC; char cPrecisionCode = '2'; const char *szFname = NULL; AVCBinFile *psFile=NULL; psInfo->numSections = 0; psInfo->pasSections = NULL; /*----------------------------------------------------------------- * Build the absolute coverage path to include in the EXP 0 line * This line usually contains the full path of the E00 file that * is being created, but since the lib does not write the output * file directly, there is no simple way to get that value. Instead, * we will use the absolute coverage path to which we add a .E00 * extension. * We need also make sure cover path is all in uppercase. *----------------------------------------------------------------*/#ifdef WIN32 if (psInfo->pszCoverPath[0] != '\\' && !(isalpha(psInfo->pszCoverPath[0]) && psInfo->pszCoverPath[1] == ':'))#else if (psInfo->pszCoverPath[0] != '/')#endif { int nLen; if (getcwd(szCWD, 74) == NULL) szCWD[0] = '\0'; /* Failed: buffer may be too small */ nLen = strlen(szCWD);#ifdef WIN32 if (nLen > 0 && szCWD[nLen -1] != '\\') strcat(szCWD, "\\");#else if (nLen > 0 && szCWD[nLen -1] != '/') strcat(szCWD, "/");#endif } pszEXPPath = CPLStrdup(CPLSPrintf("EXP 0 %s%-.*s.E00", szCWD, strlen(psInfo->pszCoverPath)-1, psInfo->pszCoverPath)); pcTmp = pszEXPPath; for( ; *pcTmp != '\0'; pcTmp++) *pcTmp = toupper(*pcTmp); /*----------------------------------------------------------------- * EXP Header *----------------------------------------------------------------*/ iSect = _AVCIncreaseSectionsArray(&(psInfo->pasSections), &(psInfo->numSections), 1); psInfo->pasSections[iSect].eType = AVCFileUnknown; psInfo->pasSections[iSect].pszName = pszEXPPath; /*----------------------------------------------------------------- * We have to try to open each file as we go for 2 reasons: * - To validate the file's signature in order to detect cases like a user * that places files such as "mystuff.txt" in the cover directory... * this has already happened and obviously lead to problems!) * - We also need to find the coverage's precision from the headers *----------------------------------------------------------------*/ /*----------------------------------------------------------------- * ARC section (arc.adf) *----------------------------------------------------------------*/ szFname = (psInfo->eCoverType==AVCCoverV7) ? "arc.adf": "arc"; if ( (iFile=CSLFindString(papszCoverDir, szFname)) != -1 && (psFile = AVCBinReadOpen(psInfo->pszCoverPath, szFname, psInfo->eCoverType, AVCFileARC, psInfo->psDBCSInfo)) != NULL) { if (nCoverPrecision == AVC_DEFAULT_PREC) nCoverPrecision = psFile->nPrecision; AVCBinReadClose(psFile); iSect = _AVCIncreaseSectionsArray(&(psInfo->pasSections), &(psInfo->numSections), 1); psInfo->pasSections[iSect].eType = AVCFileARC; psInfo->pasSections[iSect].pszName = CPLStrdup("ARC"); psInfo->pasSections[iSect].pszFilename=CPLStrdup(papszCoverDir[iFile]); } /*----------------------------------------------------------------- * CNT section (cnt.adf) *----------------------------------------------------------------*/ szFname = (psInfo->eCoverType==AVCCoverV7) ? "cnt.adf": "cnt"; if ( (iFile=CSLFindString(papszCoverDir, szFname)) != -1 && (psFile = AVCBinReadOpen(psInfo->pszCoverPath, szFname, psInfo->eCoverType, AVCFileCNT, psInfo->psDBCSInfo)) != NULL) { if (nCoverPrecision == AVC_DEFAULT_PREC) nCoverPrecision = psFile->nPrecision; AVCBinReadClose(psFile); iSect = _AVCIncreaseSectionsArray(&(psInfo->pasSections), &(psInfo->numSections), 1); psInfo->pasSections[iSect].eType = AVCFileCNT; psInfo->pasSections[iSect].pszName = CPLStrdup("CNT"); psInfo->pasSections[iSect].pszFilename=CPLStrdup(papszCoverDir[iFile]); } /*----------------------------------------------------------------- * LAB section (lab.adf) *----------------------------------------------------------------*/ szFname = (psInfo->eCoverType==AVCCoverV7) ? "lab.adf": "lab"; if ( (iFile=CSLFindString(papszCoverDir, szFname)) != -1 && (psFile = AVCBinReadOpen(psInfo->pszCoverPath, szFname, psInfo->eCoverType, AVCFileLAB, psInfo->psDBCSInfo)) != NULL) { if (nCoverPrecision == AVC_DEFAULT_PREC) nCoverPrecision = psFile->nPrecision; AVCBinReadClose(psFile); iSect = _AVCIncreaseSectionsArray(&(psInfo->pasSections), &(psInfo->numSections), 1); psInfo->pasSections[iSect].eType = AVCFileLAB; psInfo->pasSections[iSect].pszName = CPLStrdup("LAB"); psInfo->pasSections[iSect].pszFilename=CPLStrdup(papszCoverDir[iFile]); } /*----------------------------------------------------------------- * PAL section (pal.adf) *----------------------------------------------------------------*/ szFname = (psInfo->eCoverType==AVCCoverV7) ? "pal.adf": "pal"; if ( (iFile=CSLFindString(papszCoverDir, szFname)) != -1 && (psFile = AVCBinReadOpen(psInfo->pszCoverPath, szFname, psInfo->eCoverType, AVCFilePAL, psInfo->psDBCSInfo)) != NULL) { if (nCoverPrecision == AVC_DEFAULT_PREC) nCoverPrecision = psFile->nPrecision; AVCBinReadClose(psFile); iSect = _AVCIncreaseSectionsArray(&(psInfo->pasSections), &(psInfo->numSections), 1); psInfo->pasSections[iSect].eType = AVCFilePAL; psInfo->pasSections[iSect].pszName = CPLStrdup("PAL"); psInfo->pasSections[iSect].pszFilename=CPLStrdup(papszCoverDir[iFile]); } /*----------------------------------------------------------------- * TOL section (tol.adf for single precision, par.adf for double) *----------------------------------------------------------------*/ szFname = (psInfo->eCoverType==AVCCoverV7) ? "tol.adf": "tol"; if ( (iFile=CSLFindString(papszCoverDir, szFname)) != -1 && (psFile = AVCBinReadOpen(psInfo->pszCoverPath, szFname, psInfo->eCoverType, AVCFileTOL, psInfo->psDBCSInfo)) != NULL) { if (nCoverPrecision == AVC_DEFAULT_PREC) nCoverPrecision = psFile->nPrecision; AVCBinReadClose(psFile); iSect = _AVCIncreaseSectionsArray(&(psInfo->pasSections), &(psInfo->numSections), 1); psInfo->pasSections[iSect].eType = AVCFileTOL; psInfo->pasSections[iSect].pszName = CPLStrdup("TOL"); psInfo->pasSections[iSect].pszFilename=CPLStrdup(papszCoverDir[iFile]); } szFname = (psInfo->eCoverType==AVCCoverV7) ? "par.adf": "par"; if ( (iFile=CSLFindString(papszCoverDir, szFname)) != -1 && (psFile = AVCBinReadOpen(psInfo->pszCoverPath, szFname, psInfo->eCoverType, AVCFileTOL, psInfo->psDBCSInfo)) != NULL) { if (nCoverPrecision == AVC_DEFAULT_PREC) nCoverPrecision = psFile->nPrecision; AVCBinReadClose(psFile); iSect = _AVCIncreaseSectionsArray(&(psInfo->pasSections), &(psInfo->numSections), 1); psInfo->pasSections[iSect].eType = AVCFileTOL; psInfo->pasSections[iSect].pszName = CPLStrdup("TOL"); psInfo->pasSections[iSect].pszFilename=CPLStrdup(papszCoverDir[iFile]); } /*----------------------------------------------------------------- * TXT section (txt.adf) *----------------------------------------------------------------*/ szFname = (psInfo->eCoverType==AVCCoverV7) ? "txt.adf": "txt"; if ( (iFile=CSLFindString(papszCoverDir, szFname)) != -1 && (psFile = AVCBinReadOpen(psInfo->pszCoverPath, szFname, psInfo->eCoverType, AVCFileTXT, psInfo->psDBCSInfo)) != NULL) { if (nCoverPrecision == AVC_DEFAULT_PREC) nCoverPrecision = psFile->nPrecision; AVCBinReadClose(psFile); iSect = _AVCIncreaseSectionsArray(&(psInfo->pasSections), &(psInfo->numSections), 1); psInfo->pasSections[iSect].eType = AVCFileTXT; psInfo->pasSections[iSect].pszName = CPLStrdup("TXT"); psInfo->pasSections[iSect].pszFilename=CPLStrdup(papszCoverDir[iFile]); } /*----------------------------------------------------------------- * TX6 section (*.txt) * Scan the directory for files with a ".txt" extension. * Note: Never seen those in a PC Arc/Info coverage! * In weird coverages, the filename ends with "txt" but there is no "." *----------------------------------------------------------------*/ if (psInfo->eCoverType == AVCCoverV7) nCoverPrecision = _AVCE00ReadAddJabberwockySection(psInfo, AVCFileTX6, "TX6", nCoverPrecision, ".txt", papszCoverDir); else if (psInfo->eCoverType == AVCCoverWeird) nCoverPrecision = _AVCE00ReadAddJabberwockySection(psInfo, AVCFileTX6, "TX6", nCoverPrecision, "txt", papszCoverDir); /*----------------------------------------------------------------- * At this point, we should have read the coverage precsion... and if * we haven't yet then we'll just use single by default. * We'll need cPrecisionCode for some of the sections that follow. *----------------------------------------------------------------*/ if (nCoverPrecision == AVC_DOUBLE_PREC) cPrecisionCode = '3'; else cPrecisionCode = '2'; /*----------------------------------------------------------------- * SIN 2/3 and EOX lines ... ??? *----------------------------------------------------------------*/ iSect = _AVCIncreaseSectionsArray(&(psInfo->pasSections), &(psInfo->numSections), 2); psInfo->pasSections[iSect].eType = AVCFileUnknown; psInfo->pasSections[iSect].pszName = CPLStrdup("SIN X"); psInfo->pasSections[iSect].pszName[5] = cPrecisionCode; iSect++; psInfo->pasSections[iSect].eType = AVCFileUnknown; psInfo->pasSections[iSect].pszName = CPLStrdup("EOX"); iSect++; /*----------------------------------------------------------------- * LOG section (log.adf) (ends with EOL) *----------------------------------------------------------------*/ /*----------------------------------------------------------------- * PRJ section (prj.adf) (ends with EOP) *----------------------------------------------------------------*/ szFname = (psInfo->eCoverType==AVCCoverV7) ? "prj.adf": "prj"; if ( (iFile=CSLFindString(papszCoverDir, szFname)) != -1 ) { iSect = _AVCIncreaseSectionsArray(&(psInfo->pasSections), &(psInfo->numSections), 1); psInfo->pasSections[iSect].eType = AVCFilePRJ; psInfo->pasSections[iSect].pszName = CPLStrdup("PRJ"); psInfo->pasSections[iSect].pszFilename=CPLStrdup(papszCoverDir[iFile]); } /*----------------------------------------------------------------- * RXP section (*.rxp) * Scan the directory for files with a ".rxp" extension. *----------------------------------------------------------------*/ if (psInfo->eCoverType == AVCCoverV7) _AVCE00ReadAddJabberwockySection(psInfo, AVCFileRXP, "RXP", nCoverPrecision,".rxp",papszCoverDir); else if (psInfo->eCoverType == AVCCoverWeird) _AVCE00ReadAddJabberwockySection(psInfo, AVCFileRXP, "RXP", nCoverPrecision,"rxp",papszCoverDir); /*----------------------------------------------------------------- * RPL section (*.pal) * Scan the directory for files with a ".rpl" extension. *----------------------------------------------------------------*/ if (psInfo->eCoverType == AVCCoverV7) _AVCE00ReadAddJabberwockySection(psInfo, AVCFileRPL, "RPL", nCoverPrecision,".pal",papszCoverDir); else if (psInfo->eCoverType == AVCCoverWeird) _AVCE00ReadAddJabberwockySection(psInfo, AVCFileRPL, "RPL", nCoverPrecision,"rpl",papszCoverDir); /*----------------------------------------------------------------- * IFO section (tables) *----------------------------------------------------------------*/ papszTables = papszFiles = NULL; if (psInfo->eCoverType == AVCCoverV7 || psInfo->eCoverType == AVCCoverWeird) { /*------------------------------------------------------------- * Unix coverages: get tables from the ../info/arc.dir * Weird coverages: the arc.dir is similar but called "arcdr9" *------------------------------------------------------------*/ papszTables = AVCBinReadListTables(psInfo->pszInfoPath, psInfo->pszCoverName, &papszFiles, psInfo->eCoverType, psInfo->psDBCSInfo);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -