| 316 | */ |
| 317 | |
| 318 | bool FatFileSystem::createFile(const char *filename) { |
| 319 | |
| 320 | FatDirectoryIterator *it; |
| 321 | bool retval; |
| 322 | |
| 323 | // tokenise the path, must have a component |
| 324 | |
| 325 | TokenisedPathname tp(filename); |
| 326 | if(tp.getNumTokens() == 0) |
| 327 | return errorProvider.set(ErrorProvider::ERROR_PROVIDER_FILESYSTEM,E_INVALID_PATHNAME); |
| 328 | |
| 329 | // cannot create a file that exists |
| 330 | |
| 331 | if(getDirectoryIteratorPointingToFile(tp,it)) { |
| 332 | delete it; |
| 333 | return errorProvider.set(ErrorProvider::ERROR_PROVIDER_FILESYSTEM,E_FILE_EXISTS); |
| 334 | } |
| 335 | |
| 336 | // limit the range so that we get an iterator on to the parent |
| 337 | |
| 338 | tp.resetRange(); |
| 339 | tp.setRange(0,tp.getNumTokens() - 2); |
| 340 | |
| 341 | if(!FatDirectoryIterator::getInstance(*this,tp,it)) |
| 342 | return false; |
| 343 | |
| 344 | // reset the range so that we can see the filename on the end |
| 345 | |
| 346 | tp.resetRange(); |
| 347 | |
| 348 | // create the dirents for this new file |
| 349 | |
| 350 | LongNameDirentGenerator lndg(tp.last(),it->getDirectoryEntryIterator(),0,0); |
| 351 | |
| 352 | if(errorProvider.getLast() != 0) { |
| 353 | delete it; |
| 354 | return false; |
| 355 | } |
| 356 | |
| 357 | // write the dirents to the owning directory |
| 358 | |
| 359 | retval=it->getDirectoryEntryIterator().writeDirents(lndg.getDirents(),lndg.getDirentCount()); |
| 360 | delete it; |
| 361 | return retval; |
| 362 | } |
| 363 | |
| 364 | /** |
| 365 | * Open an existing file. |
no test coverage detected