1
0
Fork 0
mirror of https://gitlab.com/sbrl/GalleryShare.git synced 2018-06-12 22:45:16 +00:00

Add directory option to change the servied directory

This commit is contained in:
Starbeamrainbowlabs 2016-07-06 19:20:05 +01:00
parent 37dea995e9
commit 40be688f26
2 changed files with 15 additions and 6 deletions

View file

@ -13,17 +13,19 @@ namespace GalleryShare
{ {
class GalleryServer class GalleryServer
{ {
HttpListener server = new HttpListener();
string prefix;
int port; int port;
string servingDirectory = Environment.CurrentDirectory; string servingDirectory = Environment.CurrentDirectory;
public int Port { get { return port; } } HttpListener server = new HttpListener();
string prefix;
public GalleryServer(int inPort) public int Port { get { return port; } }
public string ServingDirectory { get { return servingDirectory; } }
public GalleryServer(string inServingDirectory, int inPort)
{ {
port = inPort; port = inPort;
servingDirectory = inServingDirectory;
prefix = string.Format("http://*:{0}/", Port); prefix = string.Format("http://*:{0}/", Port);
server.Prefixes.Add(prefix); server.Prefixes.Add(prefix);

View file

@ -7,6 +7,7 @@ namespace GalleryShare
{ {
public static int Main(string[] args) public static int Main(string[] args)
{ {
string directory = Environment.CurrentDirectory;
int port = 3333; int port = 3333;
List<string> extras = new List<string>(); List<string> extras = new List<string>();
for(int i = 0; i < args.Length; i++) for(int i = 0; i < args.Length; i++)
@ -24,13 +25,19 @@ namespace GalleryShare
case "p": case "p":
port = int.Parse(args[++i]); port = int.Parse(args[++i]);
break; break;
case "d":
case "directory":
directory = args[++i];
break;
default: default:
Console.Error.WriteLine("Error: Unknown argument '{0}'.", args[i]); Console.Error.WriteLine("Error: Unknown argument '{0}'.", args[i]);
return 1; return 1;
} }
} }
GalleryServer gserver = new GalleryServer(port); GalleryServer gserver = new GalleryServer(directory, port);
gserver.StartSync(); gserver.StartSync();
return 255; return 255;