Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Msys2 pkg-config #350

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions dokan_fuse/pkg/.PKGINFO
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Generated by hand
# Tue Sep 13 21:11:06 UTC 2016
pkgname = fuse
pkgbase = dokan_fuse
pkgver = 1.0.0-4
pkgdesc = A wrapper library that makes Dokan compatible with FUSE API
url = https://github.com/dokan-dev/dokany/wiki/FUSE
builddate = 1323390194
packager = http://mgalgs.github.io/2011/12/08/creating-arch-linux-packages-by-hand.html
size = 8192
arch = x86_64
license = GPL
license = LGPL
group = libraries
287 changes: 287 additions & 0 deletions dokan_fuse/pkg/opt/include/dokan_fuse/ScopeGuard.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,287 @@
#ifndef SCOPEGUARD_H_
#define SCOPEGUARD_H_

#include <assert.h>

template <class T>
class RefHolder
{
T& ref_;
public:
RefHolder(T& ref) : ref_(ref) {}
operator T& () const
{
return ref_;
}
private:
// Disable assignment - not implemented
RefHolder& operator=(const RefHolder&);
};

template <class T>
inline RefHolder<T> ByRef(T& t)
{
return RefHolder<T>(t);
}

class ScopeGuardImplBase
{
ScopeGuardImplBase& operator =(const ScopeGuardImplBase&);
protected:
~ScopeGuardImplBase()
{
}
ScopeGuardImplBase(const ScopeGuardImplBase& other) throw()
: dismissed_(other.dismissed_)
{
other.Dismiss();
}
template <typename J>
static void SafeExecute(J& j) throw()
{
if (!j.dismissed_)
try
{
j.Execute();
}
catch(...)
{
assert(!"Exception while performing cleanup!");
}
}

mutable bool dismissed_;
public:
ScopeGuardImplBase() throw() : dismissed_(false)
{
}
void Dismiss() const throw()
{
dismissed_ = true;
}
};

typedef const ScopeGuardImplBase& ScopeGuard;

template <typename F>
class ScopeGuardImpl0 : public ScopeGuardImplBase
{
public:
static ScopeGuardImpl0<F> MakeGuard(F fun)
{
return ScopeGuardImpl0<F>(fun);
}
~ScopeGuardImpl0() throw()
{
SafeExecute(*this);
}
void Execute()
{
fun_();
}
protected:
ScopeGuardImpl0(F fun) : fun_(fun)
{
}
F fun_;
};

template <typename F>
inline ScopeGuardImpl0<F> MakeGuard(F fun)
{
return ScopeGuardImpl0<F>::MakeGuard(fun);
}

template <typename F, typename P1>
class ScopeGuardImpl1 : public ScopeGuardImplBase
{
public:
static ScopeGuardImpl1<F, P1> MakeGuard(F fun, P1 p1)
{
return ScopeGuardImpl1<F, P1>(fun, p1);
}
~ScopeGuardImpl1() throw()
{
SafeExecute(*this);
}
void Execute()
{
fun_(p1_);
}
protected:
ScopeGuardImpl1(F fun, P1 p1) : fun_(fun), p1_(p1)
{
}
F fun_;
const P1 p1_;
};

template <typename F, typename P1>
inline ScopeGuardImpl1<F, P1> MakeGuard(F fun, P1 p1)
{
return ScopeGuardImpl1<F, P1>::MakeGuard(fun, p1);
}

template <typename F, typename P1, typename P2>
class ScopeGuardImpl2: public ScopeGuardImplBase
{
public:
static ScopeGuardImpl2<F, P1, P2> MakeGuard(F fun, P1 p1, P2 p2)
{
return ScopeGuardImpl2<F, P1, P2>(fun, p1, p2);
}
~ScopeGuardImpl2() throw()
{
SafeExecute(*this);
}
void Execute()
{
fun_(p1_, p2_);
}
protected:
ScopeGuardImpl2(F fun, P1 p1, P2 p2) : fun_(fun), p1_(p1), p2_(p2)
{
}
F fun_;
const P1 p1_;
const P2 p2_;
};

template <typename F, typename P1, typename P2>
inline ScopeGuardImpl2<F, P1, P2> MakeGuard(F fun, P1 p1, P2 p2)
{
return ScopeGuardImpl2<F, P1, P2>::MakeGuard(fun, p1, p2);
}

template <typename F, typename P1, typename P2, typename P3>
class ScopeGuardImpl3 : public ScopeGuardImplBase
{
public:
static ScopeGuardImpl3<F, P1, P2, P3> MakeGuard(F fun, P1 p1, P2 p2, P3 p3)
{
return ScopeGuardImpl3<F, P1, P2, P3>(fun, p1, p2, p3);
}
~ScopeGuardImpl3() throw()
{
SafeExecute(*this);
}
void Execute()
{
fun_(p1_, p2_, p3_);
}
protected:
ScopeGuardImpl3(F fun, P1 p1, P2 p2, P3 p3) : fun_(fun), p1_(p1), p2_(p2), p3_(p3)
{
}
F fun_;
const P1 p1_;
const P2 p2_;
const P3 p3_;
};

template <typename F, typename P1, typename P2, typename P3>
inline ScopeGuardImpl3<F, P1, P2, P3> MakeGuard(F fun, P1 p1, P2 p2, P3 p3)
{
return ScopeGuardImpl3<F, P1, P2, P3>::MakeGuard(fun, p1, p2, p3);
}

//************************************************************

template <class Obj, typename MemFun>
class ObjScopeGuardImpl0 : public ScopeGuardImplBase
{
public:
static ObjScopeGuardImpl0<Obj, MemFun> MakeObjGuard(Obj& obj, MemFun memFun)
{
return ObjScopeGuardImpl0<Obj, MemFun>(obj, memFun);
}
~ObjScopeGuardImpl0() throw()
{
SafeExecute(*this);
}
void Execute()
{
(obj_.*memFun_)();
}
protected:
ObjScopeGuardImpl0(Obj& obj, MemFun memFun)
: obj_(obj), memFun_(memFun) {}
Obj& obj_;
MemFun memFun_;
};

template <class Obj, typename MemFun>
inline ObjScopeGuardImpl0<Obj, MemFun> MakeObjGuard(Obj& obj, MemFun memFun)
{
return ObjScopeGuardImpl0<Obj, MemFun>::MakeObjGuard(obj, memFun);
}

template <class Obj, typename MemFun, typename P1>
class ObjScopeGuardImpl1 : public ScopeGuardImplBase
{
public:
static ObjScopeGuardImpl1<Obj, MemFun, P1> MakeObjGuard(Obj& obj, MemFun memFun, P1 p1)
{
return ObjScopeGuardImpl1<Obj, MemFun, P1>(obj, memFun, p1);
}
~ObjScopeGuardImpl1() throw()
{
SafeExecute(*this);
}
void Execute()
{
(obj_.*memFun_)(p1_);
}
protected:
ObjScopeGuardImpl1(Obj& obj, MemFun memFun, P1 p1)
: obj_(obj), memFun_(memFun), p1_(p1) {}
Obj& obj_;
MemFun memFun_;
const P1 p1_;
};

template <class Obj, typename MemFun, typename P1>
inline ObjScopeGuardImpl1<Obj, MemFun, P1> MakeObjGuard(Obj& obj, MemFun memFun, P1 p1)
{
return ObjScopeGuardImpl1<Obj, MemFun, P1>::MakeObjGuard(obj, memFun, p1);
}

template <class Obj, typename MemFun, typename P1, typename P2>
class ObjScopeGuardImpl2 : public ScopeGuardImplBase
{
public:
static ObjScopeGuardImpl2<Obj, MemFun, P1, P2> MakeObjGuard(Obj& obj, MemFun memFun, P1 p1, P2 p2)
{
return ObjScopeGuardImpl2<Obj, MemFun, P1, P2>(obj, memFun, p1, p2);
}
~ObjScopeGuardImpl2() throw()
{
SafeExecute(*this);
}
void Execute()
{
(obj_.*memFun_)(p1_, p2_);
}
protected:
ObjScopeGuardImpl2(Obj& obj, MemFun memFun, P1 p1, P2 p2)
: obj_(obj), memFun_(memFun), p1_(p1), p2_(p2) {}
Obj& obj_;
MemFun memFun_;
const P1 p1_;
const P2 p2_;
};

template <class Obj, typename MemFun, typename P1, typename P2>
inline ObjScopeGuardImpl2<Obj, MemFun, P1, P2> MakeObjGuard(Obj& obj, MemFun memFun, P1 p1, P2 p2)
{
return ObjScopeGuardImpl2<Obj, MemFun, P1, P2>::MakeObjGuard(obj, memFun, p1, p2);
}

#define CONCATENATE_DIRECT(s1, s2) s1##s2
#define CONCATENATE(s1, s2) CONCATENATE_DIRECT(s1, s2)
#define ANONYMOUS_VARIABLE(str) CONCATENATE(str, __COUNTER__)

#define ON_BLOCK_EXIT ScopeGuard ANONYMOUS_VARIABLE(scopeGuard) = MakeGuard
#define ON_BLOCK_EXIT_OBJ ScopeGuard ANONYMOUS_VARIABLE(scopeGuard) = MakeObjGuard

#endif //SCOPEGUARD_H_
64 changes: 64 additions & 0 deletions dokan_fuse/pkg/opt/include/dokan_fuse/dokanfuse.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#ifndef DOKANFUSE_H_
#define DOKANFUSE_H_

#include <string>

#define FUSE_THREAD_COUNT 10
#define DOKAN_DLL L"dokan" DOKAN_MAJOR_API_VERSION L".dll"

struct fuse_config
{
unsigned int umask;
unsigned int fileumask, dirumask;
const char *fsname, *volname;
int help;
int debug;
int setsignals;
unsigned int timeoutInSec;
int networkDrive;
};

struct fuse_session
{
fuse_chan *ch;
};

struct fuse_chan
{
fuse_chan():ResolvedDokanMain(NULL), ResolvedDokanUnmount(NULL), ResolvedDokanRemoveMountPoint(NULL), dokanDll(NULL) {}
~fuse_chan();

//This method dynamically loads DOKAN functions
bool init();

typedef int (__stdcall *DokanMainType)(PDOKAN_OPTIONS,PDOKAN_OPERATIONS);
typedef BOOL (__stdcall *DokanUnmountType)(WCHAR DriveLetter);
typedef BOOL (__stdcall *DokanRemoveMountPointType)(LPCWSTR MountPoint);
DokanMainType ResolvedDokanMain;
DokanUnmountType ResolvedDokanUnmount;
DokanRemoveMountPointType ResolvedDokanRemoveMountPoint;

std::string mountpoint;
private:
HMODULE dokanDll;
};

struct fuse
{
bool within_loop;
std::unique_ptr<fuse_chan> ch;
fuse_session sess;
fuse_config conf;

struct fuse_operations ops;
void *user_data;

fuse() : within_loop(), user_data()
{
memset(&conf,0,sizeof(fuse_config));
memset(&sess, 0, sizeof(fuse_session));
memset(&ops, 0, sizeof(fuse_operations));
}
};

#endif //DOKANFUSE_H_
Loading