xrootd
|
00001 #ifndef _OSS_PATH_H 00002 #define _OSS_PATH_H 00003 /******************************************************************************/ 00004 /* */ 00005 /* X r d O s s P a t h . h h */ 00006 /* */ 00007 /* (c) 2008 by the Board of Trustees of the Leland Stanford, Jr., University */ 00008 /* All Rights Reserved */ 00009 /* Produced by Andrew Hanushevsky for Stanford University under contract */ 00010 /* DE-AC02-76-SFO0515 with the Department of Energy */ 00011 /******************************************************************************/ 00012 00013 // $Id$ 00014 00015 #include <string.h> 00016 00017 class XrdOssPath 00018 { 00019 public: 00020 00021 struct fnInfo 00022 { 00023 const char *Path; 00024 const char *Sfx; // Of length sfxLen! 00025 char *Slash; 00026 int Plen; 00027 }; 00028 00029 static const char xChar = '%'; 00030 00031 static const int sfxLen = 4; 00032 00033 static int Convert(char *dst, int dln, const char *oldP, const char *newP); 00034 00035 static 00036 const char *Extract(char *path, char *lbuf, int &lbsz); 00037 00038 static char *genPath(const char *inPath, const char *cgrp, char *sfx); 00039 00040 static char *genPFN(fnInfo &Info, char *buff, int blen, const char *Path=0); 00041 00042 static char *genPFN(char *dst, int dln, const char *src); 00043 00044 static int getCname(const char *path, char *Cache, char *lbuf=0, int lbsz=0); 00045 00046 static 00047 inline int isXA(const char *path) {return path[strlen(path)-1] == xChar;} 00048 00049 enum theSfx {isBase =0, isAnew =1, 00050 sfxMigF=1, isFail=2, isLock =3, isPin =4, isStage=5, sfxMigL=5, 00051 sfxMemF=5, isMkeep=6, isMlock=7, isMmap=8, sfxMemL=8, 00052 isPfn=9, sfxLast=9, sfxNum =10 00053 }; 00054 00055 static 00056 const char *Sfx[sfxNum]; 00057 00058 static const int chkMem = 0x01; 00059 static const int chkMig = 0x02; 00060 static const int chkPfn = 0x04; 00061 static const int chkAll = 0x07; 00062 00063 static theSfx pathType(const char *Path, int chkWhat=chkAll); 00064 00065 static void Trim2Base(char *eP); 00066 00067 XrdOssPath() {} 00068 ~XrdOssPath() {} 00069 00070 private: 00071 static char *bin2hex(char *inbuff, int dlen, char *buff); 00072 static int Init(char *pfnPfx); 00073 static char *posCname(char *lbuf, int lbsz, int &cnsz); 00074 00075 static char h2c[16]; 00076 }; 00077 #endif