static int setup_source(struct Source *p,char *frag) {
struct stat filestat;
// Open the fragment file rw if possible, else ro
- range = strrchr( frag, '/' ); // last '/'
- p->filename = range? strndup( frag, range - frag ) : frag;
+ // First try the fragment in full, thereafter with range appendix
+ if ( stat( frag, &filestat ) == 0 ) {
+ p->filename = strdup( frag );
+ range = 0;
+ } else {
+ range = strrchr( frag, '/' ); // last '/'
+ p->filename = range? strndup( frag, range - frag ) : frag;
+ }
p->fd = open( p->filename, O_RDWR );
int rdonly = 0;
if ( p->fd < 0 ) {
perror( p->filename );
return 1; // Error return
}
- if ( stat( p->filename, &filestat ) ) {
+ if ( ( range == 0 ) && stat( p->filename, &filestat ) ) {
perror( p->filename );
return 1;
}