/ OpenTableFile: Open a DOS/UNIX table file as a mapped file. */ /
| 100 | /* OpenTableFile: Open a DOS/UNIX table file as a mapped file. */ |
| 101 | /***********************************************************************/ |
| 102 | bool MAPFAM::OpenTableFile(PGLOBAL g) |
| 103 | { |
| 104 | char filename[_MAX_PATH]; |
| 105 | size_t len; |
| 106 | MODE mode = Tdbp->GetMode(); |
| 107 | PFBLOCK fp; |
| 108 | PDBUSER dbuserp = (PDBUSER)g->Activityp->Aptr; |
| 109 | |
| 110 | #if defined(_DEBUG) |
| 111 | // Insert mode is no more handled using file mapping |
| 112 | assert(mode != MODE_INSERT); |
| 113 | #endif // _DEBUG |
| 114 | |
| 115 | /*********************************************************************/ |
| 116 | /* We used the file name relative to recorded datapath. */ |
| 117 | /*********************************************************************/ |
| 118 | PlugSetPath(filename, To_File, Tdbp->GetPath()); |
| 119 | |
| 120 | /*********************************************************************/ |
| 121 | /* Under Win32 the whole file will be mapped so we can use it as */ |
| 122 | /* if it were entirely read into virtual memory. */ |
| 123 | /* Firstly we check whether this file have been already mapped. */ |
| 124 | /*********************************************************************/ |
| 125 | if (mode == MODE_READ) { |
| 126 | for (fp = dbuserp->Openlist; fp; fp = fp->Next) |
| 127 | if (fp->Type == TYPE_FB_MAP && !stricmp(fp->Fname, filename) |
| 128 | && fp->Count && fp->Mode == mode) |
| 129 | break; |
| 130 | |
| 131 | if (trace(1)) |
| 132 | htrc("Mapping file, fp=%p\n", fp); |
| 133 | |
| 134 | } else |
| 135 | fp = NULL; |
| 136 | |
| 137 | if (fp) { |
| 138 | /*******************************************************************/ |
| 139 | /* File already mapped. Just increment use count and get pointer. */ |
| 140 | /*******************************************************************/ |
| 141 | fp->Count++; |
| 142 | Memory = fp->Memory; |
| 143 | len = fp->Length; |
| 144 | } else { |
| 145 | /*******************************************************************/ |
| 146 | /* If required, delete the whole file if no filtering is implied. */ |
| 147 | /*******************************************************************/ |
| 148 | bool del; |
| 149 | HANDLE hFile; |
| 150 | MEMMAP mm; |
| 151 | |
| 152 | del = mode == MODE_DELETE && !Tdbp->GetNext(); |
| 153 | |
| 154 | if (del) |
| 155 | DelRows = Cardinality(g); |
| 156 | |
| 157 | /*******************************************************************/ |
| 158 | /* Create the mapping file object. */ |
| 159 | /*******************************************************************/ |
nothing calls this directly
no test coverage detected