autoFileInMemorySet FileInMemorySet_createFromDirectoryContents (const char32 *dirpath, const char32 *fileGlobber) { try { structMelderDir parent { { 0 } }; Melder_pathToDir (dirpath, &parent); autoStrings thee = Strings_createAsFileList (Melder_cat (dirpath, U"/", fileGlobber)); if (thy numberOfStrings < 1) { Melder_throw (U"No files found."); } autoFileInMemorySet me = FileInMemorySet_create (); for (long i = 1; i <= thy numberOfStrings; i ++) { structMelderFile file = { 0 }; MelderDir_getFile (& parent, thy strings [i], & file); autoFileInMemory fim = FileInMemory_create (& file); my addItem_move (fim.move()); } return me; } catch (MelderError) { Melder_throw (U"FileInMemorySet not created from directory \"", dirpath, U"\" for files that match \"", fileGlobber, U"\"."); } }
autoMovie Movie_openFromSoundFile (MelderFile file) { try { autoMovie me = Thing_new (Movie); autoSound sound = Sound_readFromSoundFile (file); autoMelderString fileNameHead; MelderString_copy (& fileNameHead, Melder_fileToPath (file)); char32 *extensionLocation = str32rchr (fileNameHead.string, U'.'); if (! extensionLocation) extensionLocation = & fileNameHead.string [fileNameHead.length]; *extensionLocation = U'\0'; fileNameHead.length = extensionLocation - fileNameHead.string; autoStrings strings = Strings_createAsFileList (Melder_cat (fileNameHead.string, U"*.png")); struct structMelderDir folder; MelderFile_getParentDir (file, & folder); Movie_init (me.peek(), sound.transfer(), Melder_dirToPath (& folder), strings.transfer()); return me; } catch (MelderError) { Melder_throw (U"Movie object not read from file ", file, U"."); } }
FilesInMemory FilesInMemory_createFromDirectoryContents (const wchar_t *dirpath, const wchar *fileGlobber) { try { structMelderDir parent = { { 0 } }; Melder_pathToDir (dirpath, &parent); autoMelderString path; MelderString_append (&path, dirpath, L"/", fileGlobber); autoStrings thee = Strings_createAsFileList (path.string); if (thy numberOfStrings < 1) { Melder_throw ("No files found."); } autoFilesInMemory me = FilesInMemory_create (); for (long i = 1; i <= thy numberOfStrings; i++) { structMelderFile file = { 0 }; MelderDir_getFile (&parent, thy strings[i], &file); autoFileInMemory fim = FileInMemory_create (&file); Collection_addItem (me.peek(), fim.transfer()); } return me.transfer(); } catch (MelderError) { Melder_throw ("FilesInMemory not created from directory \"", dirpath, "\" for files that match \"", fileGlobber, "\"."); } }