| 127 | /***********************************************************************/ |
| 128 | |
| 129 | PRAGMA_DISABLE_CHECK_STACK_FRAME |
| 130 | |
| 131 | bool TDBMUL::InitFileNames(PGLOBAL g) |
| 132 | { |
| 133 | #define PFNZ 4096 |
| 134 | #define FNSZ (_MAX_DRIVE+_MAX_DIR+_MAX_FNAME+_MAX_EXT) |
| 135 | PTDBDIR dirp; |
| 136 | PSZ pfn[PFNZ]; |
| 137 | PSZ filename; |
| 138 | int rc, n = 0; |
| 139 | |
| 140 | if (trace(1)) |
| 141 | htrc("in InitFileName: fn[]=%d\n", FNSZ); |
| 142 | |
| 143 | filename = (char*)PlugSubAlloc(g, NULL, FNSZ); |
| 144 | |
| 145 | // The sub table may need to refer to the Table original block |
| 146 | Tdbp->SetTable(To_Table); // Was not set at construction |
| 147 | |
| 148 | PlugSetPath(filename, Tdbp->GetFile(g), Tdbp->GetPath()); |
| 149 | |
| 150 | if (trace(1)) |
| 151 | htrc("InitFileName: fn='%s'\n", filename); |
| 152 | |
| 153 | if (Mul != 2) { |
| 154 | /*******************************************************************/ |
| 155 | /* To_File is a multiple name with special characters */ |
| 156 | /*******************************************************************/ |
| 157 | if (Mul == 1) |
| 158 | dirp = new(g) TDBDIR(PlugDup(g, filename)); |
| 159 | else // Mul == 3 (Subdir) |
| 160 | dirp = new(g) TDBSDR(PlugDup(g, filename)); |
| 161 | |
| 162 | if (dirp->OpenDB(g)) |
| 163 | return true; |
| 164 | |
| 165 | if (trace(1) && Mul == 3) { |
| 166 | int nf = ((PTDBSDR)dirp)->FindInDir(g); |
| 167 | htrc("Number of files = %d\n", nf); |
| 168 | } // endif trace |
| 169 | |
| 170 | while (true) |
| 171 | if ((rc = dirp->ReadDB(g)) == RC_OK) { |
| 172 | #if defined(_WIN32) |
| 173 | strcat(strcpy(filename, dirp->Drive), dirp->Direc); |
| 174 | #else // !_WIN32 |
| 175 | strcpy(filename, dirp->Direc); |
| 176 | #endif // !_WIN32 |
| 177 | strcat(strcat(filename, dirp->Fname), dirp->Ftype); |
| 178 | pfn[n++] = PlugDup(g, filename); |
| 179 | } else |
| 180 | break; |
| 181 | |
| 182 | dirp->CloseDB(g); |
| 183 | |
| 184 | if (rc == RC_FX) |
| 185 | return true; |
| 186 |
nothing calls this directly
no test coverage detected