08e706732530e4f62bc903a67064350bfc7d5601 braney Fri Feb 15 14:20:10 2013 -0800 changes to UDC to support twoBit library using it #8072 diff --git src/lib/udc.c src/lib/udc.c index 3697678..97ed816 100644 --- src/lib/udc.c +++ src/lib/udc.c @@ -429,30 +429,45 @@ // Convert UTC to localtime tm = localtime(&tUtc); t = mktimeFromUtc(tm); if (t == -1) { /* Handle error */; errAbort("mktimeFromUtc failed while converting FTP UTC last-modified time %ld to local time", (long) tUtc); } retInfo->size = size; retInfo->updateTime = t; return TRUE; } /********* Non-protocol-specific bits **********/ +boolean udcFastReadString(struct udcFile *f, char buf[256]) +/* Read a string into buffer, which must be long enough + * to hold it. String is in 'writeString' format. */ +{ +UBYTE bLen; +int len; +if (!udcReadOne(f, bLen)) + return FALSE; +if ((len = bLen)> 0) + udcMustRead(f, buf, len); +buf[len] = 0; +return TRUE; +} + +void msbFirstWriteBits64(FILE *f, bits64 x); static char *fileNameInCacheDir(struct udcFile *file, char *fileName) /* Return the name of a file in the cache dir, from the cache root directory on down. * Do a freeMem on this when done. */ { int dirLen = strlen(file->cacheDir); int nameLen = strlen(fileName); char *path = needMem(dirLen + nameLen + 2); memcpy(path, file->cacheDir, dirLen); path[dirLen] = '/'; memcpy(path+dirLen+1, fileName, nameLen); return path; } static void udcNewCreateBitmapAndSparse(struct udcFile *file, @@ -1424,30 +1439,37 @@ if (retSize != NULL) *retSize = size; return buf; } struct lineFile *udcWrapShortLineFile(char *url, char *cacheDir, size_t maxSize) /* Read in entire short (up to maxSize) url into memory and wrap a line file around it. * The cacheDir may be null in which case udcDefaultDir() will be used. If maxSize * is zero then a default value (currently 64 meg) will be used. */ { if (maxSize == 0) maxSize = 64 * 1024 * 1024; char *buf = udcFileReadAll(url, cacheDir, maxSize, NULL); return lineFileOnString(url, TRUE, buf); } +void udcSeekCur(struct udcFile *file, bits64 offset) +/* Seek to a particular position in file. */ +{ +file->offset += offset; +mustLseek(file->fdSparse, offset, SEEK_CUR); +} + void udcSeek(struct udcFile *file, bits64 offset) /* Seek to a particular position in file. */ { file->offset = offset; mustLseek(file->fdSparse, offset, SEEK_SET); } bits64 udcTell(struct udcFile *file) /* Return current file position. */ { return file->offset; } static long bitRealDataSize(char *fileName) /* Return number of real bytes indicated by bitmaps */