forked from wyang007/rucioN2N-for-Xcache
-
Notifications
You must be signed in to change notification settings - Fork 2
/
cacheQuery.cc
48 lines (40 loc) · 1.16 KB
/
cacheQuery.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/*
* Author: Wei Yang (SLAC National Accelerator Laboratory / Stanford University, 2019)
*/
using namespace std;
#include <stdio.h>
#include <string.h>
#include <string>
#include <errno.h>
#include <iostream>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include "XrdVersion.hh"
#include "XrdOuc/XrdOucCacheCM.hh"
#include "XrdPosix/XrdPosixCache.hh"
//______________________________________________________________________________
XrdPosixCache *myCache;
extern "C" {
XrdOucCacheCMInit_t XrdOucCacheCMInit(XrdPosixCache &Cache,
XrdSysLogger *Logger,
const char *Config,
const char *Parms,
XrdOucEnv *envP)
{
myCache = &Cache;
}
};
XrdVERSIONINFO(XrdOucCacheCMInit,CacheCM-4-RUCIO);
int cachedFileIsComplete(std::string url, std::string *localfile)
{
int rc;
char pfn[1024];
char *myurl = strdup(url.c_str());
rc = myCache->CacheQuery(myurl, 0);
myCache->CachePath(myurl, pfn, 1024);
free(myurl);
*localfile = pfn;
return rc;
}