{ // SSEdit_Extensions: // Returns True if the specified filename (paths allowed) exists. p1 = path & filename to check. extension exFilesystem bool fsFileExists(string); // Copies source to destination, returns True if succeeded. p1 = source, p2 = dest, p3 = boolean overwrite if exists extension exFilesystem bool fsCopy(string, string, bool); // Caches a folder for enumeration. Returns # of files + dirs. Use fsEnumFile/fsEnumDir to get names. p1 = folder to enumerate extension exFilesystem int fsEnumFolder(string); // Returns specified filename in folder cached by fsEnumFolder. p1 = index of file, use fsGetEnumFileCount() to find upper boundary extension exFilesystem string fsGetEnumFile(int); // Returns # of files in folder cached by fsEnumFolder. extension exFilesystem int fsGetEnumFileCount(); // Returns specified subfolder name in folder cached by fsEnumFolder. p1 = index of subfolder, use fsGetEnumFolderCount() to find upper boundary extension exFilesystem string fsGetEnumFolder(int); // Returns # of subdirs in folder cached by fsEnumFolder. extension exFilesystem int fsGetEnumFolderCount(); } // ************************************************************************************************************ // Called once when the plugin is started. Do one time setup here. // ************************************************************************************************************ function Init() { // This plugin demonstrates how to use the exFilesystem extension to copy files and enumerate files // and folders. All output is made to the Brass VM debug window as this removes any need for more // code to setup drawing and potentially confuse the requirements. // Create a test file in C:\Sample.txt. This code is not required for the exFilesystem extensions, it // just gives us a file to work with. file SampleFile; fopen(SampleFile, "C:\\sample.txt"); fwriteline(SampleFile, "This is a sample file to be copied"); fclose(SampleFile); // Demonstration of exFilesystem begins. // First make sure we have the sample file if(fsFileExists("C:\\sample.txt")) { print "Sample file found, copying..."; // Copy sample.txt to copy.txt, and overwrite copy.txt if it already exists if(fsCopy("C:\\sample.txt", "C:\\copy.txt", True) == True) print "Copy successful."; else print "Copy failed!"; } // Now enumerate all the files and subfolders in the root of C:\. First we must instruct // the extension to cache all the files and folders. iTotal will contain the total number // of files + folders in C:\ (we don't need to store this value, it's for info only) int iTotal = fsEnumFolder("C:\\"); // Now that the folder has been cached we can enumerate it. First let's get the directories. // We do this by requesting each directory in the sequence until we've accessed all of them. // fsGetEnumFolderCount() returns the number of subfolders in the cached folder for(int iDirs = 0; iDirs < fsGetEnumFolderCount(); iDirs++) { // fsGetEnumFolder() returns the name of the folder at the supplied index print "Dir: " + fsGetEnumFolder(iDirs); } // Now do the same for files. This works on an identical principle to folder enumeration. for(int iFiles = 0; iFiles < fsGetEnumFileCount(); iFiles++) { // fsGetEnumFolder() returns the name of the folder at the supplied index print "File: " + fsGetEnumFile(iFiles); } }