Exemplo n.º 1
0
		Directory ResolveDirectory(Directory directory, IEnumerable<string> children)
		{
			if (!children.Any())
				return directory;

			string childName = children.First();

			Directory info = directory.GetDirectories()
				.Where(x => string.Compare(x.Name.GetName(), childName, true) == 0)
				.SingleOrDefault();

			if (info != null)
			{
				return ResolveDirectory(info, children.Skip(1));
			}

			File file = directory.GetFiles()
				.Where(x => string.Compare(x.Name.GetName(), childName, true) == 0)
				.SingleOrDefault();

			if (file == null)
				throw new InvalidOperationException("Could not get directory: " + childName);

			if (Path.GetExtension(file.Name.GetName()) == ".zip")
			{
				var zipFileDirectory = new ZipFileDirectory(file.Name.Name);
				return ResolveDirectory(zipFileDirectory, children.Skip(1));
			}

			throw new InvalidOperationException("Could not resolve the rest of the path: " + childName);
		}
Exemplo n.º 2
0
        Directory ResolveDirectory(Directory directory, IEnumerable <string> children)
        {
            if (!children.Any())
            {
                return(directory);
            }

            string childName = children.First();

            Directory info = directory.GetDirectories()
                             .Where(x => string.Compare(x.Name.GetName(), childName, true) == 0)
                             .SingleOrDefault();

            if (info != null)
            {
                return(ResolveDirectory(info, children.Skip(1)));
            }

            File file = directory.GetFiles()
                        .Where(x => string.Compare(x.Name.GetName(), childName, true) == 0)
                        .SingleOrDefault();

            if (file == null)
            {
                throw new InvalidOperationException("Could not get directory: " + childName);
            }

            if (Path.GetExtension(file.Name.GetName()) == ".zip")
            {
                var zipFileDirectory = new ZipFileDirectory(file.Name.Name);
                return(ResolveDirectory(zipFileDirectory, children.Skip(1)));
            }

            throw new InvalidOperationException("Could not resolve the rest of the path: " + childName);
        }
Exemplo n.º 3
0
 void ProcessNewFile(FileCreated message)
 {
     if (message.Path.EndsWith("bottle"))
     {
         Directory dir = new ZipFileDirectory(PathName.GetPathName(message.Path));
         try
         {
             _actionToTake(dir);
         }
         catch (Exception ex)
         {
             string msg = "There was an error processing the bottle '{0}'".FormatWith(message.Path);
             throw new BottleException(msg, ex);
         }
     }
 }
Exemplo n.º 4
0
 public void A_ZippedFile_Directory()
 {
     _zf = new ZipFileDirectory(new RelativePathName(_zippedFile));
 }
Exemplo n.º 5
0
        File ResolveFile(Directory directoryInfo, IEnumerable<string> children)
        {
            if (!children.Any())
                throw new InvalidOperationException("Unable to resolve file: " + directoryInfo.Name);

            string childName = children.First();

            Trace.WriteLine("Parsing out: " + childName);

            Directory info = directoryInfo.GetDirectories()
                .Where(x => string.Compare(x.Name.GetName(), childName, true) == 0)
                .SingleOrDefault();

            if (info != null)
            {
                Trace.WriteLine(string.Format("Found directory: {0}", info.Name));
                return ResolveFile(info, children.Skip(1));
            }

            File file = directoryInfo.GetFiles()
                .Where(x => string.Compare(x.Name.GetName(), childName, true) == 0)
                .SingleOrDefault();

            if (file == null)
                throw new InvalidOperationException("Could not get file: " + childName);

            if (!children.Skip(1).Any())
                return file;

            if (Path.GetExtension(file.Name.GetName()) == ".zip")
            {
                var zipFileDirectory = new ZipFileDirectory(file.Name.Name);
                return ResolveFile(zipFileDirectory, children.Skip(1));
            }

            throw new NotImplementedException();
        }
Exemplo n.º 6
0
 public void SetUp()
 {
     zf = new ZipFileDirectory(new RelativePathName(_zippedFile));
 }
Exemplo n.º 7
0
 public ZipFile(string filename)
 {
     this.filename = filename;
     zipfile       = Ionic.Zip.ZipFile.Read(filename);
     file_system   = new ZipFileDirectory(zipfile.Name, zipfile, Application.streamingAssetsPath);
 }