Commit ece02b61 authored by Birte Kristina Friesel's avatar Birte Kristina Friesel
Browse files

Use new path_is_url helper instead of repeated strncmp chains

parent ad285742
Loading
Loading
Loading
Loading
+1 −5
Original line number Diff line number Diff line
@@ -211,11 +211,7 @@ void add_file_to_filelist_recursively(char *origpath, unsigned char level)
		if (path[len - 1] == '/')
			path[len - 1] = '\0';

		if ((!strncmp(path, "http://", 7))
				|| (!strncmp(path, "https://", 8))
				|| (!strncmp(path, "ftp://", 6))
				|| (!strncmp(path, "file://", 7))) {
			/* Its a url */
		if (path_is_url(path)) {
			D(("Adding url %s to filelist\n", path));
			filelist = gib_list_add_front(filelist, feh_file_new(path));
			/* We'll download it later... */
+1 −5
Original line number Diff line number Diff line
@@ -242,11 +242,7 @@ int feh_load_image(Imlib_Image * im, feh_file * file)
	if (!file || !file->filename)
		return 0;

	/* Handle URLs */
	if ((!strncmp(file->filename, "http://", 7))
			|| (!strncmp(file->filename, "https://", 8))
			|| (!strncmp(file->filename, "ftp://", 6))
			|| (!strncmp(file->filename, "file://", 7))) {
	if (path_is_url(file->filename)) {
		image_source = SRC_HTTP;

		if ((tmpname = feh_http_load_image(file->filename)) == NULL)
+1 −3
Original line number Diff line number Diff line
@@ -602,9 +602,7 @@ char *feh_thumbnail_get_name_uri(char *name)
	char *cwd, *uri = NULL;

	/* FIXME: what happens with http, https, and ftp? MTime etc */
	if ((strncmp(name, "http://", 7) != 0) &&
	    (strncmp(name, "https://", 8) != 0) && (strncmp(name, "ftp://", 6) != 0)
	    && (strncmp(name, "file://", 7) != 0)) {
	if (!path_is_url(name)) {

		/* make sure it's an absoulte path */
		/* FIXME: add support for ~, need to investigate if it's expanded
+9 −0
Original line number Diff line number Diff line
@@ -143,6 +143,15 @@ char *estrjoin(const char *separator, ...)
	return string;
}

char path_is_url(char *path) {
	if ((!strncmp(path, "http://", 7))
			|| (!strncmp(path, "https://", 8))
			|| (!strncmp(path, "ftp://", 6))
			|| (!strncmp(path, "file://", 7)))
		return 1;
	return 0;
}

/* free the result please */
char *feh_unique_filename(char *path, char *basename)
{
+1 −0
Original line number Diff line number Diff line
@@ -36,6 +36,7 @@ char *_estrdup(char *s);
void *_emalloc(size_t n);
void *_erealloc(void *ptr, size_t n);
char *estrjoin(const char *separator, ...);
char path_is_url(char *path);
char *feh_unique_filename(char *path, char *basename);
char *ereadfile(char *path);