libdap++  Updated for version 3.8.2
HTTPCacheMacros.h
Go to the documentation of this file.
00001 /*
00002  * HTTPCacheMacros.h
00003  *
00004  *  Created on: Dec 28, 2011
00005  *      Author: jimg
00006  */
00007 
00008 #ifndef HTTPCACHEMACROS_H_
00009 #define HTTPCACHEMACROS_H_
00010 
00011 #ifdef WIN32
00012 #include <direct.h>
00013 #include <time.h>
00014 #include <fcntl.h>
00015 #define MKDIR(a,b) _mkdir((a))
00016 #define UMASK(a) _umask((a))
00017 
00018 #if 0
00019 #define REMOVE(a) do { \
00020         int s = remove((a)); \
00021         if (s != 0) \
00022             throw InternalErr(__FILE__, __LINE__, "Cache error; could not remove file: " + long_to_string(s)); \
00023     } while(0)
00024 #endif
00025 
00026 #define REMOVE_BOOL(a) remove((a))
00027 #define REMOVE(a) ((void)remove((a)))
00028 #define MKSTEMP(a) _open(_mktemp((a)),_O_CREAT,_S_IREAD|_S_IWRITE)
00029 #define DIR_SEPARATOR_CHAR '\\'
00030 #define DIR_SEPARATOR_STR "\\"
00031 
00032 #else
00033 #include <cerrno>
00034 #define MKDIR(a,b) mkdir((a), (b))
00035 #define UMASK(a) umask((a))
00036 
00037 #if 0
00038 // Replaced this with something that signals errors. jhrg 12/28/2011
00039 // A great idea, but it breaks things in ways that complicate
00040 // testing. Push this change forward to H 1.9. jhrg 12/28/2011
00041 #define REMOVE(a) do { \
00042         errno = 0; \
00043         int s = remove((a)); \
00044         if (s != 0) \
00045             throw InternalErr(__FILE__, __LINE__, "Cache error; could not remove file: " + long_to_string(errno)); \
00046     } while(0)
00047 #endif
00048 
00049 #define REMOVE_BOOL(a) remove((a))
00050 #define REMOVE(a) ((void)remove((a)))
00051 
00052 #define MKSTEMP(a) mkstemp((a))
00053 #define DIR_SEPARATOR_CHAR '/'
00054 #define DIR_SEPARATOR_STR "/"
00055 #endif
00056 
00057 #ifdef WIN32
00058 #define CACHE_LOCATION "\\tmp\\"
00059 #define CACHE_ROOT "dods-cache\\"
00060 #else
00061 #define CACHE_LOCATION "/tmp/"
00062 #define CACHE_ROOT "dods-cache/"
00063 #endif
00064 
00065 #define CACHE_INDEX ".index"
00066 #define CACHE_LOCK ".lock"
00067 #define CACHE_META ".meta"
00068 #define CACHE_EMPTY_ETAG "@cache@"
00069 
00070 
00071 #endif /* HTTPCACHEMACROS_H_ */