Exemple #1
0
int glue_saveProject(const char *folderPath, const char *projName) {

	if (gIsProject(folderPath)) {
		puts("[glue] the project folder already exists");
		// don't exit
	}
	else if (!gMkdir(folderPath)) {
		puts("[glue] unable to make project directory!");
		return 0;
	}

	/* copy all samples inside the folder. Takes and logical ones are saved
	 * with glue_saveSample() */

	for (int i=0; i<MAX_NUM_CHAN; i++) {

		if (G_Mixer.chan[i] == NULL)
			continue;

		/* update the new samplePath: everything now comes from the project folder */

		char samplePath[PATH_MAX];
		sprintf(samplePath, "%s/%s.wav", folderPath, G_Mixer.chan[i]->name.c_str());

		/* remove any existing file */

		if (gFileExists(samplePath))
			remove(samplePath);
		if (glue_saveSample(i, samplePath))
			G_Mixer.chan[i]->pathfile = samplePath;
	}

	std::string projNameClean = stripExt(projName);
	char gptcPath[PATH_MAX];
	sprintf(gptcPath, "%s/%s.gptc", folderPath, projNameClean.c_str());
	glue_savePatch(gptcPath, projName);

	return 1;
}
Exemple #2
0
void gdBrowser::__cb_save_patch() {

	if (strcmp(name->value(), "") == 0) {  /// FIXME glue business
		gdAlert("Please choose a file name.");
		return;
	}

	/* if name->value() contains ".gptc" */

	char ext[6] = ".gptc";
	if (strstr(name->value(), ".gptc") != NULL)
		ext[0] = '\0';

	char fullpath[PATH_MAX];
	sprintf(fullpath, "%s/%s%s", where->value(), name->value(), ext);
	if (gFileExists(fullpath))
		if (!gdConfirmWin("Warning", "File exists: overwrite?"))
			return;

	if (glue_savePatch(fullpath, name->value(), false)) // false == not a project
		do_callback();
	else
		gdAlert("Unable to save the patch!");
}