dtagfs/source/app.d

51 lines
1022 B
D
Raw Normal View History

2016-10-16 01:03:31 +02:00
module dtagfs.app;
import std.stdio;
import std.getopt;
import std.array;
import dfuse.fuse;
import dtagfs.filesystem;
import dtagfs.tagprovider;
2016-10-16 02:49:56 +02:00
import dtagfs.dublincore;
2016-10-16 01:03:31 +02:00
void main(string[] args)
{
//TODO: Make tag provider(s) configurable
2016-10-16 01:27:28 +02:00
if(args.length < 3)
2016-10-16 01:03:31 +02:00
{
stderr.writeln("usage: dtagfs <source> <mount point> [-f] [-o option[,options...]]");
return;
}
2016-10-16 01:27:28 +02:00
auto source = args[1];
auto mountPoint = args[2];
2016-10-16 01:03:31 +02:00
2016-10-16 02:49:56 +02:00
TagProvider[] tagProviders = [new DublinCoreTagProvider()];
2016-10-16 01:03:31 +02:00
string[] mountOptions;
2016-11-08 04:35:22 +01:00
bool foreground;
2016-10-16 01:03:31 +02:00
arraySep = ",";
auto options = getopt(
2016-10-16 01:27:28 +02:00
args,
2016-10-16 01:03:31 +02:00
"o", &mountOptions,
2016-11-08 04:35:22 +01:00
"f|foreground", &foreground
2016-10-16 01:03:31 +02:00
);
2016-11-08 04:35:22 +01:00
auto filesystem = mount(source, mountPoint, tagProviders, mountOptions, foreground);
2016-10-16 01:03:31 +02:00
}
2016-11-08 04:35:22 +01:00
FileSystem mount(string source, string mountPoint, TagProvider[] tagProviders, string[] options, bool foreground)
2016-10-16 01:03:31 +02:00
{
auto filesystem = new FileSystem(source, tagProviders);
2016-11-08 04:35:22 +01:00
auto fuse = new Fuse("dtagfs", foreground, false);
2016-10-16 01:03:31 +02:00
fuse.mount(filesystem, mountPoint, options);
return filesystem;
}