~ubuntu-branches/ubuntu/maverick/mpd/maverick-proposed

« back to all changes in this revision

Viewing changes to src/input/file_input_plugin.c

  • Committer: Andrew Mitchell
  • Date: 2010-06-09 21:45:30 UTC
  • mfrom: (1.1.13 upstream)
  • Revision ID: ajmitch@ubuntu.com-20100609214530-9j1wdxdlmm5e52aj
Merging shared upstream rev into target branch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
36
36
        int fd, ret;
37
37
        struct stat st;
38
38
 
39
 
        char* pathname = g_strdup(filename);
40
 
 
41
39
        if (filename[0] != '/')
42
 
        {
43
 
                g_free(pathname);
44
40
                return false;
45
 
        }
46
 
 
47
 
        if (stat(filename, &st) < 0) {
48
 
                char* slash = strrchr(pathname, '/');
49
 
                *slash = '\0';
50
 
        }
51
 
 
52
 
        fd = open(pathname, O_RDONLY);
 
41
 
 
42
        fd = open(filename, O_RDONLY);
53
43
        if (fd < 0) {
54
44
                is->error = errno;
55
45
                g_debug("Failed to open \"%s\": %s",
56
 
                        pathname, g_strerror(errno));
57
 
                g_free(pathname);
 
46
                        filename, g_strerror(errno));
58
47
                return false;
59
48
        }
60
49
 
64
53
        if (ret < 0) {
65
54
                is->error = errno;
66
55
                close(fd);
67
 
                g_free(pathname);
68
56
                return false;
69
57
        }
70
58
 
71
59
        if (!S_ISREG(st.st_mode)) {
72
 
                g_debug("Not a regular file: %s", pathname);
 
60
                g_debug("Not a regular file: %s", filename);
73
61
                is->error = EINVAL;
74
62
                close(fd);
75
 
                g_free(pathname);
76
63
                return false;
77
64
        }
78
65
 
86
73
        is->data = GINT_TO_POINTER(fd);
87
74
        is->ready = true;
88
75
 
89
 
        g_free(pathname);
90
 
 
91
76
        return true;
92
77
}
93
78