Exemple #1
0
/* make sure path names are correct for OS */
static void clean_paths(Main *main)
{
	struct BPathIterator *bpi;
	char filepath_expanded[1024];
	Scene *scene;

	for(BLI_bpathIterator_init(&bpi, main, main->name, BPATH_USE_PACKED); !BLI_bpathIterator_isDone(bpi); BLI_bpathIterator_step(bpi)) {
		BLI_bpathIterator_getPath(bpi, filepath_expanded);

		BLI_clean(filepath_expanded);

		BLI_bpathIterator_setPath(bpi, filepath_expanded);
	}

	BLI_bpathIterator_free(bpi);

	for(scene= main->scene.first; scene; scene= scene->id.next) {
		BLI_clean(scene->r.pic);
	}
}
Exemple #2
0
static PyObject *bpy_blend_paths(PyObject *UNUSED(self), PyObject *args, PyObject *kw)
{
	struct BPathIterator *bpi;
	PyObject *list, *st; /* stupidly big string to be safe */
	/* be sure there is low chance of the path being too short */
	char filepath_expanded[1024];
	const char *lib;

	int absolute= 0;
	static const char *kwlist[]= {"absolute", NULL};

	if (!PyArg_ParseTupleAndKeywords(args, kw, "|i:blend_paths", (char **)kwlist, &absolute))
		return NULL;

	list= PyList_New(0);

	for (BLI_bpathIterator_init(&bpi, G.main, G.main->name, 0); !BLI_bpathIterator_isDone(bpi); BLI_bpathIterator_step(bpi)) {
		/* build the list */
		if (absolute) {
			BLI_bpathIterator_getPathExpanded(bpi, filepath_expanded);
		}
		else {
			lib= BLI_bpathIterator_getLib(bpi);
			if (lib && (BLI_path_cmp(lib, BLI_bpathIterator_getBasePath(bpi)))) { /* relative path to the library is NOT the same as our blendfile path, return an absolute path */
				BLI_bpathIterator_getPathExpanded(bpi, filepath_expanded);
			}
			else {
				BLI_bpathIterator_getPath(bpi, filepath_expanded);
			}
		}
		st= PyUnicode_DecodeFSDefault(filepath_expanded);

		PyList_Append(list, st);
		Py_DECREF(st);
	}

	BLI_bpathIterator_free(bpi);

	return list;
}