//**************************************************************************** // //! Main function //! //! \param none //! //! //! \return None. // //**************************************************************************** void main() { FIL fp; FATFS fs; FRESULT res; DIR dir; UINT Size; // // Initialize Board configurations // BoardInit(); // // Muxing for Enabling UART_TX and UART_RX. // PinMuxConfig(); // // Set the SD card clock as output pin // MAP_PinDirModeSet(PIN_07,PIN_DIR_MODE_OUT); // // Enable Pull up on data // MAP_PinConfigSet(PIN_06,PIN_STRENGTH_4MA, PIN_TYPE_STD_PU); // // Enable Pull up on CMD // MAP_PinConfigSet(PIN_08,PIN_STRENGTH_4MA, PIN_TYPE_STD_PU); // // Initialising the Terminal. // InitTerm(); // // Clearing the Terminal. // ClearTerm(); // // Display the Banner // Message("\n\n\n\r"); Message("\t\t ********************************************\n\r"); Message("\t\t CC3200 SDHost Fatfs Demo Application \n\r"); Message("\t\t ********************************************\n\r"); Message("\n\n\n\r"); // // Enable MMCHS // MAP_PRCMPeripheralClkEnable(PRCM_SDHOST,PRCM_RUN_MODE_CLK); // // Reset MMCHS // MAP_PRCMPeripheralReset(PRCM_SDHOST); // // Configure MMCHS // MAP_SDHostInit(SDHOST_BASE); // // Configure card clock // MAP_SDHostSetExpClk(SDHOST_BASE, MAP_PRCMPeripheralClockGet(PRCM_SDHOST),15000000); f_mount(&fs,"0",1); res = f_opendir(&dir,"/"); if( res == FR_OK) { Message("Opening root directory.................... [ok]\n\n\r"); Message("/\n\r"); ListDirectory(&dir); } else { Message("Opening root directory.................... [Failed]\n\n\r"); } Message("\n\rReading user file...\n\r"); res = f_open(&fp,USERFILE,FA_READ); if(res == FR_OK) { f_read(&fp,pBuffer,100,&Size); Report("Read : %d Bytes\n\n\r",Size); Report("%s",pBuffer); f_close(&fp); } else { Report("Failed to open %s\n\r",USERFILE); } Message("\n\n\rWriting system file...\n\r"); res = f_open(&fp,SYSFILE,FA_CREATE_ALWAYS|FA_WRITE); if(res == FR_OK) { f_write(&fp,SYSTEXT,sizeof(SYSTEXT),&Size); Report("Wrote : %d Bytes",Size); res = f_close(&fp); } else { Message("Failed to create a new file\n\r"); } while(1) { } }
int main(int argc, char* argv[]) { bool all = false; const char* argv0 = argv[0]; for ( int i = 1; i < argc; i++ ) { const char* arg = argv[i]; if ( arg[0] != '-' || !arg[1] ) continue; argv[i] = NULL; if ( !strcmp(arg, "--") ) break; if ( arg[1] != '-' ) { char c; while ( (c = *++arg) ) switch ( c ) { default: fprintf(stderr, "%s: unknown option -- '%c'\n", argv0, c); help(stderr, argv0); exit(1); } } else if ( !strcmp(arg, "--help") ) help(stdout, argv0), exit(0); else if ( !strcmp(arg, "--version") ) version(stdout, argv0), exit(0); else if ( !strcmp(arg, "-a") ) all = true; else { fprintf(stderr, "%s: unknown option: %s\n", argv0, arg); help(stderr, argv0); exit(1); } } compact_arguments(&argc, &argv); if ( argc == 1 ) error(1, 0, "No initrd specified"); const char* initrd = argv[1]; if ( argc == 2 ) error(1, 0, "No command specified"); const char* cmd = argv[2]; if ( argc == 3 ) error(1, 0, "No path specified"); const char* path = argv[3]; int fd = open(initrd, O_RDONLY); if ( fd < 0 ) { error(1, errno, "open: %s", initrd); } initrd_superblock_t* sb = GetSuperBlock(fd); if ( !sb ) { error(1, errno, "read: %s", initrd); } if ( path[0] != '/' ) { error(1, ENOENT, "%s", path); } initrd_inode_t* root = GetInode(fd, sb, sb->root); if ( !root ) { error(1, errno, "read: %s", initrd); } initrd_inode_t* inode = ResolvePath(fd, sb, root, path+1); if ( !inode ) { error(1, errno, "%s", path); } free(root); if ( !strcmp(cmd, "cat") ) { if ( !PrintFile(fd, sb, inode) ) { error(1, errno, "%s", path); } } else if ( !strcmp(cmd, "ls") ) { initrd_inode_t* dir = inode; if ( !ListDirectory(fd, sb, dir, all) ) { error(1, errno, "%s", path); } } else { fprintf(stderr, "%s: unrecognized command: %s", argv0, cmd); exit(1); } free(inode); free(sb); close(fd); return 0; }
FileEx::FileEx(const TCHAR* initDir) : pos(0), path(initDir), lineheight(25), linecount(10) , topline(0) { ListDirectory(); }
void FileEx::GoParent() { go_parent_dir(); ListDirectory(); }
// Finds all the filenames in the specified directory that match the specified // filter. Directory should be like "textures" or "textures/". // Filter can be NULL or "" or "*.bmp" or "map_*" or "map_*.txt" // Set _longResults to true if you want results like "textures/blah.bmp" // or false for "blah.bmp" LList<char *> *FileSystem::ListArchive(char *_dir, char *_filter, bool fullFilename) { LList<char *> *results = NULL; // // List the search directories for( int i = 0; i < m_searchPath.Size(); ++i ) { char searchPathFilename[512]; snprintf( searchPathFilename, sizeof(searchPathFilename), "%s%s", m_searchPath[i], _dir ); searchPathFilename[ sizeof(searchPathFilename) - 1 ] = '\x0'; LList<char *> *results2 = ListDirectory( searchPathFilename, _filter, fullFilename ); if( !results ) { results = results2; } else { ListArchiveFilterResults( results, results2 ); results2->EmptyAndDelete(); delete results2; } } // // List the localisation directory char localisationFilename[512]; snprintf( localisationFilename, sizeof(localisationFilename), "localisation/%s", _dir ); localisationFilename[ sizeof(localisationFilename) - 1 ] = '\0'; LList<char *> *results3 = ListDirectory( localisationFilename, _filter, fullFilename ); if( !results ) { results = results3; } else { ListArchiveFilterResults( results, results3 ); results3->EmptyAndDelete(); delete results3; } // // List the base data directory LList<char *> *results4 = ListDirectory( _dir, _filter, fullFilename ); ListArchiveFilterResults( results, results4 ); results4->EmptyAndDelete(); delete results4; // // List the pre-loaded resource files if (m_archiveFiles.Size() > 0) { if(_filter == NULL || _filter[0] == '\0') { _filter = "*"; } DArray <char *> *unfilteredResults = m_archiveFiles.ConvertIndexToDArray(); for (int i = 0; i < unfilteredResults->Size(); ++i) { if (!unfilteredResults->ValidIndex(i)) continue; char *fullname = unfilteredResults->GetData(i); char *dirPart = (char *) GetDirectoryPart( fullname ); if( stricmp( dirPart, _dir ) == 0 ) { char *filePart = (char *) GetFilenamePart( fullname ); int result = WildCmp(_filter, filePart); if (result != 0) { if( !fullFilename ) OrderedInsert(results, filePart); else OrderedInsert(results, fullname); } } } delete unfilteredResults; } return results; }
bool ScreenGameplay7K::LoadSongAudio() { if (!Music) { Music = std::make_shared<AudioStream>(); Music->SetPitch(Speed); if (MySong->SongFilename.length() && Music->Open((MySong->SongDirectory / MySong->SongFilename).c_path())) { Log::Printf("Stream for %s succesfully opened.\n", MySong->SongFilename.c_str()); } else { if (!CurrentDiff->IsVirtual) { // Caveat: Try to autodetect an mp3/ogg file. std::vector<std::string> DirCnt; auto SngDir = MySong->SongDirectory; SngDir.ListDirectory(DirCnt, Directory::FS_REG); for (auto i = DirCnt.begin(); i != DirCnt.end(); ++i) { if (Directory(*i).GetExtension() == "mp3" || Directory(*i).GetExtension() == "ogg") if (Music->Open((SngDir / *i).c_path())) return true; } Music = nullptr; Log::Printf("Unable to load song (Path: %s)\n", MySong->SongFilename.c_str()); return false; // Quit; couldn't find audio for a chart that requires it. } } } // Load samples. if (strstr(MySong->SongFilename.c_str(), ".ojm")) { Log::Printf("Loading OJM.\n"); OJMAudio = std::make_shared<AudioSourceOJM>(this); OJMAudio->SetPitch(Speed); OJMAudio->Open((MySong->SongDirectory / MySong->SongFilename).c_path()); for (int i = 1; i <= 2000; i++) { std::shared_ptr<SoundSample> Snd = OJMAudio->GetFromIndex(i); if (Snd != nullptr) Keysounds[i].push_back(Snd); } } else if (CurrentDiff->SoundList.size() || CurrentDiff->Data->TimingInfo->GetType() == VSRG::TI_BMS) { Log::Printf("Loading samples... "); if (CurrentDiff->Data->TimingInfo->GetType() == VSRG::TI_BMS) { Directory dir = MySong->SongDirectory; bool isBMSON = ((VSRG::BMSTimingInfo*)CurrentDiff->Data->TimingInfo.get())->IsBMSON; if (isBMSON) { int wavs = 0; std::map<int, SoundSample> audio; auto &slicedata = CurrentDiff->Data->SliceData; // do bmson loading for (auto wav : slicedata.Slices) { for (auto sounds : wav.second) { CheckInterruption(); // load basic sound if (!audio[sounds.first].IsValid()) { Directory path = (dir / slicedata.AudioFiles[sounds.first]); audio[sounds.first].SetPitch(Speed); if (!audio[sounds.first].Open(path.c_path())) throw std::exception(Utility::Format("Unable to load %s.", slicedata.AudioFiles[sounds.first]).c_str()); Log::Printf("BMSON: Load sound %s\n", path.c_path()); } audio[sounds.first].Slice(sounds.second.Start, sounds.second.End); Keysounds[wav.first].push_back(audio[sounds.first].CopySlice()); wavs++; } Keysounds[wav.first].shrink_to_fit(); } Log::Printf("BMSON: Generated %d sound objects.\n", wavs); } } for (auto i = CurrentDiff->SoundList.begin(); i != CurrentDiff->SoundList.end(); ++i) { auto ks = std::make_shared<SoundSample>(); ks->SetPitch(Speed); #ifdef WIN32 std::wstring sd = Utility::Widen(MySong->SongDirectory) + L"/" + Utility::Widen(i->second); ks->Open(Utility::Narrow(sd).c_str()); #else ks->Open((MySong->SongDirectory + "/" + i->second).c_str()); #endif Keysounds[i->first].push_back(ks); CheckInterruption(); } } return true; }