| 2025 | // append their chart information to the chart list. |
| 2026 | |
| 2027 | void OpenDir(CONST char *szDir) |
| 2028 | { |
| 2029 | #ifdef PC |
| 2030 | char szPath[cchSzMax], szFile[cchSzMax]; |
| 2031 | struct _finddata_t fi; |
| 2032 | long hFile; |
| 2033 | flag fAll = us.fWriteOld, fHaveFile; |
| 2034 | |
| 2035 | // Only look at *.as extension files. |
| 2036 | sprintf(szPath, "%s\\*.%s", szDir, !fAll ? "as" : "*"); |
| 2037 | hFile = _findfirst(szPath, &fi); |
| 2038 | fHaveFile = (hFile != -1); |
| 2039 | while (fHaveFile) { |
| 2040 | if (fi.name[0] == '.' || (fi.attrib & _A_SUBDIR) != 0) |
| 2041 | goto LNext; |
| 2042 | // Skip over astrolog.as, atlas.as, and timezone.as if present. |
| 2043 | if (!fAll && (FEqSzI(fi.name, DEFAULT_INFOFILE) || FEqSzI(fi.name, |
| 2044 | DEFAULT_ATLASFILE) || FEqSzI(fi.name, DEFAULT_TIMECHANGE))) |
| 2045 | goto LNext; |
| 2046 | sprintf(szFile, "%s\\%s", szDir, fi.name); |
| 2047 | if (!FInputData(szFile)) |
| 2048 | break; |
| 2049 | if (!FAppendCIList(&ciCore)) |
| 2050 | break; |
| 2051 | LNext: |
| 2052 | fHaveFile = _findnext(hFile, &fi) == 0; |
| 2053 | } |
| 2054 | _findclose(hFile); |
| 2055 | #else |
| 2056 | char szPath[cchSzMax], szFile[cchSzMax], *pchFile, *pch; |
| 2057 | DIR *dir; |
| 2058 | struct dirent *ent; |
| 2059 | flag fAll = us.fWriteOld; |
| 2060 | |
| 2061 | dir = opendir(szDir); |
| 2062 | if (dir != NULL) { |
| 2063 | loop { |
| 2064 | ent = readdir(dir); |
| 2065 | if (ent == NULL) |
| 2066 | break; |
| 2067 | pchFile = ent->d_name; |
| 2068 | if (pchFile[0] == '.') |
| 2069 | continue; |
| 2070 | for (pch = pchFile; *pch; pch++) |
| 2071 | ; |
| 2072 | if (!fAll && !(pch - pchFile > 3 && |
| 2073 | pch[-3] == '.' && pch[-2] == 'a' && pch[-1] == 's')) |
| 2074 | continue; |
| 2075 | // Skip over astrolog.as, atlas.as, and timezone.as if present. |
| 2076 | if (!fAll && (FEqSzI(pchFile, DEFAULT_INFOFILE) || FEqSzI(pchFile, |
| 2077 | DEFAULT_ATLASFILE) || FEqSzI(pchFile, DEFAULT_TIMECHANGE))) |
| 2078 | continue; |
| 2079 | sprintf(szFile, "%s/%s", szDir, pchFile); |
| 2080 | if (!FInputData(szFile)) |
| 2081 | break; |
| 2082 | if (!FAppendCIList(&ciCore)) |
| 2083 | break; |
| 2084 | } |
no test coverage detected