/********************************************************************************************** * getPeerBufferMap *********************************************************************************************/ const uint8_t* File::getPeerBufferMap(Peer peer) { FileEntry* entry = getFileEntry(peer); if (entry != (FileEntry*) (0)) { return entry->getBufferMap(); } return (uint8_t*) (0); }
/********************************************************************************************** * setPeerBufferMap *********************************************************************************************/ bool File::setPeerBufferMap(Peer peer, uint8_t* map) { FileEntry* entry = getFileEntry(peer); if (entry != (FileEntry*) (0)) { return entry->setBufferMap(map); } return false; }
/********************************************************************************************** * addSeeder *********************************************************************************************/ void File::addSeeder(Peer peer) { FileEntry* entry = getFileEntry(peer); if (entry != (FileEntry*) (0)) { entry->seed = true; seeders++; } }
/********************************************************************************************** * addLeecher *********************************************************************************************/ void File::addLeecher (Peer peer) { FileEntry * entry = getFileEntry (peer); if (entry != (FileEntry*) (0)) { entry->leech = true; leechers++; } }
/** FUSE API method to read all file entries in a given directory. This is a convenience method that is used to read all the root directory entries into the given buffer. This function currently handles only root directory entries. Consequently, the path must be "/". Refer to the solution from previous exercise to help complete this function. The getFileEntry() function defined in FAT12Utils.h will come in handy here. \return This function returns -ENOENT if path is invalid. Otherwise it returns 0 for success. */ int fat12_readdir(const char *path, void *buf, fuse_fill_dir_t filler, off_t offset, struct fuse_file_info *fi) { // Tell compiler we are intentionally not using 2 parameters (void) offset; (void) fi; // Only handle root directory on FAT-12. if (strcmp(path, "/") != 0) { return -ENOENT; } filler(buf,".", NULL,0); filler(buf,"..",NULL,0); int i; for(i = 0; i > 0; i++){ struct FileEntry fe; if(getFileEntry(path+1, &fe) != "SUCCESS"){ return -ENOENT; } /**char buf[12]; strncopy(buf,fe.fileName,11); buf[11]='\0';*/ filler(buf, fe.fileName, NULL, 0); } return 0; }
const GamFileEntry *GamArchive::getGroupFileEntry(uint32 sceneId, uint32 resId) { const GamGroupEntry *groupEntry = getGroupEntry(sceneId); if (!groupEntry) error("GamArchive::getFileEntry() Group %08X not found", sceneId); const GamFileEntry *fileEntry = getFileEntry(groupEntry, resId); if (!fileEntry) error("GamArchive::getFileEntry() File %08X in group %08X not found", resId, sceneId); return fileEntry; }
/********************************************************************************************** * removeSeeder *********************************************************************************************/ void File::removeSeeder(Peer peer) { FileEntry* entry = getFileEntry(peer); if (entry != (FileEntry*) (0)) { entry->seed = false; seeders--; if (!entry->leech && !entry->seed) { removeFileEntry(peer); } } }