예제 #1
0
        public void a_CreateNewStandardFileSystem()
        {
            sfs  = StandardFileSystem.Create(rootDir);
            root = sfs.GetRoot();

            Assert.AreEqual("Test", root.Name);
        }
예제 #2
0
        static void Main(string[] args)
        {
            /*
             * byte[] b = new byte[]{ 0, 1, 2, 3, 4, 5 };
             * NoSeekMemoryStream n = new NoSeekMemoryStream(b);
             *
             * // n.Seek(1,System.IO.SeekOrigin.Begin);
             * byte[] b2 = new byte[1000];
             * n.Read(b2, 0, 1000);
             * foreach(var i in b2) { Console.Out.Write(i); }
             *
             * UnitTests u = new UnitTests();
             * u.runTests();
             */
            StandardFileSystem fs = StandardFileSystem.Create("C:\\Users\\lt_va\\Documents");

            //StandardFileSystem fs = StandardFileSystem.Create("C:\\Users\\lt_va\\Documents");
            WebServer.AddService(new FilesWebService(fs));
            WebServer.Start(9000, 10);
            //Thread.Sleep(10);
            //WebServer.Stop();

            //TestBigNum test = new TestBigNum();

            //ConcatStreamUnitTests.Test();
            //NoSeekMemoryStreamTests.Test();
        }
예제 #3
0
파일: tests.cs 프로젝트: Drew-Miller/CS422
        public void SDirTests()
        {
            StandardFileSystem sfs2 = StandardFileSystem.Create("/Users/drewm");

            Dir422 dir1 = sfs2.GetRoot().GetDir("Desktop");

            //Assert.NotNull(dir1.CreateFile("hello.txt"));
            //Assert.NotNull(dir1.CreateFile("Test.txt"));

            Assert.NotNull(dir1.CreateFile("A"));
            string datastring = "new data";

            byte[] info = new UTF8Encoding(true).GetBytes(datastring);

            File422 a = dir1.GetFile("A");

            if (a is StdFSFile)
            {
                Assert.NotNull(a);
                a = a as StdFSFile;

                FileStream fs = (FileStream)((StdFSFile)a).OpenReadWrite();
                fs.Write(info, 0, info.Length);
                fs.Close();
            }

            else
            {
                Assert.IsTrue(false);
            }
        }
예제 #4
0
        static int Main(string[] args)
        {
            StandardFileSystem sfs2 = StandardFileSystem.Create("/Users/drewm");

            Dir422 dir1 = sfs2.GetRoot().GetDir("Desktop");

            //Assert.NotNull(dir1.CreateFile("hello.txt"));
            //Assert.NotNull(dir1.CreateFile("Test.txt"));

            dir1.CreateFile("A");
            string datastring = "new data";

            byte[] info = new UTF8Encoding(true).GetBytes(datastring);

            File422 a = dir1.GetFile("A");

            if (a is StdFSFile)
            {
                a = a as StdFSFile;

                FileStream fs = (FileStream)((StdFSFile)a).OpenReadWrite();
                fs.Write(info, 0, info.Length);
                fs.Close();
            }

            return(0);
        }
예제 #5
0
        public static void Main(string[] args)
        {
            StandardFileSystem sfs = StandardFileSystem.Create("/Users");

            WebServer.AddService(new FileWebService(sfs));
            WebServer.Start(13000, 32);
            WebServer.Stop();
        }
예제 #6
0
파일: Tests.cs 프로젝트: devjeetr/CPTS-422
        public static void Main()
        {
            StandardFileSystem a = StandardFileSystem.Create("/home/devjeetroy/");

            //Console.WriteLine (a.GetRoot ().GetFiles ()[0].Name);
            WebServer.AddService(new FilesWebService(a));
            WebServer.Start(8080, 64);
        }
예제 #7
0
        public static void Main(string[] args)
        {
            WebServer.AddService(new FilesWebService(StandardFileSystem.Create("/")));

            Console.WriteLine("Starting server on port {0}", PORT);

            WebServer.Start(PORT, 10);

            Console.ReadKey();
        }
예제 #8
0
        // Methods
        public static StandardFileSystem Create(string rootDir)
        {
            // create rootDir
            DirectoryInfo dir  = Directory.CreateDirectory(rootDir);
            string        cwd  = Directory.GetCurrentDirectory();
            StdFSDir      root = new StdFSDir(cwd + "/" + rootDir, rootDir, null);

            StandardFileSystem fileSystem = new StandardFileSystem(root);

            return(fileSystem);
        }
예제 #9
0
        public static void Main(string[] args)
        {
            WebServer.Start(4220, 1);
            FilesWebService fileService = new FilesWebService(StandardFileSystem.Create("/home/jakeknott/Desktop"));

            WebServer.AddService(fileService);

            while (true)
            {
            }
        }
예제 #10
0
        public static StandardFileSystem Create(string path)
        {
            StandardFileSystem sfs = null;


            if (Directory.Exists(path))
            {
                sfs = new StandardFileSystem(path); // /a/b/c/d -> parent = null
            }

            return(sfs);
        }
예제 #11
0
파일: tests.cs 프로젝트: Drew-Miller/CS422
        public void SSysContains()
        {
            StandardFileSystem sfs2 = StandardFileSystem.Create("/Users/drewm");

            Dir422 dir1 = sfs2.GetRoot().GetDir("Desktop");
            Dir422 dir2 = dir1.GetDir("Ableton");
            Dir422 dir3 = dir2.GetDir("wav files");

            File422 f = dir3.GetFile("Cloud.wav");

            Assert.IsTrue(sfs2.Contains(f));
        }
예제 #12
0
파일: tests.cs 프로젝트: Drew-Miller/CS422
        public void SFileTests()
        {
            StandardFileSystem sfs2 = StandardFileSystem.Create("/Users/drewm");

            Dir422 dir1 = sfs2.GetRoot().GetDir("Desktop");
            Dir422 dir2 = dir1.GetDir("Ableton");
            Dir422 dir3 = dir2.GetDir("wav files");

            File422 f = dir3.GetFile("Cloud.wav");

            StringAssert.AreEqualIgnoringCase(f.Name, "Cloud.wav");
            StringAssert.AreEqualIgnoringCase(f.Parent.Name, "wav files");
        }
예제 #13
0
        public void STDSystemTest()
        {
            if (Directory.Exists("./NewFolder"))
            {
                Directory.Delete("./NewFolder", true);
            }

            //Creat root directory
            Directory.CreateDirectory("./NewFolder");
            StandardFileSystem mySys = StandardFileSystem.Create("./NewFolder");

            RunTest(mySys);
        }
예제 #14
0
        static void master()
        {
            const string DefaultTemplate = "HTTP/1.1 200 OK\r\n" +
                                           "Content-Type:text/html\r\n" +
                                           "\r\n\r\n" +
                                           "<html>ID Number: {0}</br>" +
                                           "DateTime.Now: {1}</br>" +
                                           "Requested URL: {2}</html>";

            WebServer.Start(1337, 64);

            WebService service = new FilesWebService(StandardFileSystem.Create("/Users/ellio/desktop"));

            WebServer.AddService(service);
        }
예제 #15
0
        public static bool Start(int port, int numberOfThreads, string rootName)
        {
            bool active = true;

            _tcpClientCollection = new BlockingCollection <TcpClient>();
            _threadCount         = numberOfThreads <= 0 ?  64 : numberOfThreads;

            //Create the filesystem from the root path har coded above
            _fileSystem = StandardFileSystem.Create(rootName);

            // add services that this server can use
            _webServices = new List <WebService>();
            AddService(new DemoService());
            AddService(new FilesWebService(_fileSystem));

            // Set TCP
            Console.WriteLine("starting TCPListener on port " + port);
            _listener = new TcpListener(IPAddress.Any, port);
            _listener.Start();
            Console.WriteLine("listening on port: " + port);

            // Create and start all threads
            _threadPool = new Thread[_threadCount];
            for (int i = 0; i < _threadCount; i++)
            {
                _threadPool [i] = new Thread(new ThreadStart(ConcurrentlyProcessTcpClient));
            }

            for (int i = 0; i < _threadCount; i++)
            {
                //• Accept	new	TCP	socket	connection
                TcpClient client = new TcpClient();
                client = _listener.AcceptTcpClient();
                _tcpClientCollection.Add(client);

                //• Get a	thread	from	the	thread	pool	and	pass	it	the	TCP	socket
                _threadPool [i].Start();
            }

            Stop();

            return(true);
        }
예제 #16
0
파일: Program.cs 프로젝트: genewlee/CS422
        static void Main()
        {
            //Mac
            //WebServer.AddService(new FilesWebService(StandardFileSystem.Create("/Users/Gene/Desktop")));

            //Linux
            WebServer.AddService(new FilesWebService(StandardFileSystem.Create("/home/gene/Desktop")));

            /*var mfs = new MemoryFileSystem();
             * var root = mfs.GetRoot();
             * root.CreateDir("FooDir");
             * root.CreateFile("barFile");
             * var barFile = root.GetFile("barFile");
             * var barFileStream = barFile.OpenReadWrite();
             * barFileStream.Write(Encoding.ASCII.GetBytes("Hello World"), 0, Encoding.ASCII.GetBytes("Hello World").Length);
             * barFileStream.Close();
             * WebServer.AddService(new FilesWebService(mfs));*/

            WebServer.Start(8080, 64);
        }
예제 #17
0
파일: tests.cs 프로젝트: Drew-Miller/CS422
        public void SgetDir_File()
        {
            StandardFileSystem sfs2 = StandardFileSystem.Create("/Users/drewm");
            Dir422             dir1 = sfs2.GetRoot().GetDir("Desktop");

            Assert.NotNull(dir1);


            Dir422 dir2 = dir1.GetDir("Ableton");

            Assert.NotNull(dir2);


            Dir422 dir3 = dir2.GetDir("wav files");

            Assert.NotNull(dir3);


            Assert.NotNull(dir3.GetFile("Cloud.wav"));
        }
예제 #18
0
        [SetUp]                                        //like @Before
        public void Init()                             //create standard file system
        {
            Assert.True(Directory.Exists(rootString)); //make sure this directory exists.

            stdFS = StandardFileSystem.Create(rootString);
            root  = stdFS.GetRoot();

            Dir422 one = root.CreateDir("one");
            Dir422 two = root.CreateDir("two");

            Dir422 curr1 = one;
            Dir422 curr2 = two;

            // /one/a/b/c and /two/a/b/c
            for (int i = 0; i < 3; i++)
            {
                curr1 = curr1.CreateDir(((char)('a' + i)).ToString());
                curr2 = curr2.CreateDir(((char)('a' + i)).ToString());
            }
        }
예제 #19
0
        public static void Main(string[] args)
        {
            WebServer.Start(3000, 10);

            //Add the DemoService to the list of available services
            WebServer.AddService(new DemoService());
            WebServer.AddService(new FilesWebService(StandardFileSystem.Create("/Users")));

            while (true)
            {
                string input = Console.ReadLine();

                if (input == "Stop")
                {
                    WebServer.Stop();
                    break;
                }
            }

            /*RequestValidator rv = new RequestValidator();
             * string putr = "PUT /hello.htm HTTP/1.1\r\nUser-Agent: Mozilla/4.0 (compatible; MSIE5.01; Windows NT)\r\nHost: www.tutorialspoint.com\r\nAccept-Language: en-us\r\nConnection: Keep-Alive\r\nContent-type: text/html\r\nContent-Length: 182\r\n\r\n";
             * rv.testValidator(putr);*/
        }
예제 #20
0
파일: tests.cs 프로젝트: Drew-Miller/CS422
        public void SdifferentRoot()
        {
            StandardFileSystem sfs2 = StandardFileSystem.Create("/Users");

            StringAssert.AreNotEqualIgnoringCase("/Users", sfs2.GetRoot().Name);
        }
예제 #21
0
파일: tests.cs 프로젝트: Drew-Miller/CS422
        public void SbadRoot()
        {
            StandardFileSystem sfs2 = StandardFileSystem.Create("asdf");

            Assert.Null(sfs2);
        }