68b33514365f969f034d97a6e9652e6feb944c77 kent Tue Aug 31 12:04:47 2010 -0700 Made it so that netUrlOpenSockets (and hence netUrlOpen and netLineFileOpen) can handle a plain unix file name as well as a URL. diff --git src/lib/net.c src/lib/net.c index 93955bb..ffe9d93 100644 --- src/lib/net.c +++ src/lib/net.c @@ -967,38 +967,44 @@ } } } lineFileClose(&lf); } else status = errno; return status; } int netUrlOpenSockets(char *url, int *retCtrlSocket) /* Return socket descriptor (low-level file handle) for read()ing url data, * or -1 if error. * If retCtrlSocket is non-NULL and url is FTP, set *retCtrlSocket * to the FTP control socket which is left open for a persistent connection. - * close(result) (and close(*retCtrlSocket) if applicable) when done. */ + * close(result) (and close(*retCtrlSocket) if applicable) when done. + * If url is missing :// then it's just treated as a file. */ { -if (startsWith("http://",url) || startsWith("https://",url) || (stringIn("://", url) == NULL)) +if (stringIn("://", url) == NULL) + return open(url, O_RDONLY); +else + { + if (startsWith("http://",url) || startsWith("https://",url)) return netGetOpenHttp(url); else if (startsWith("ftp://",url)) return netGetOpenFtpSockets(url, retCtrlSocket); else errAbort("Sorry, can only netUrlOpen http, https and ftp currently, not '%s'", url); + } return -1; } int netUrlOpen(char *url) /* Return socket descriptor (low-level file handle) for read()ing url data, * or -1 if error. Just close(result) when done. */ { return netUrlOpenSockets(url, NULL); } struct dyString *netSlurpFile(int sd) /* Slurp file into dynamic string and return. */ { char buf[4*1024]; int readSize;