public static bool AllowedToAccess(this Path chjailedRootPath, string otherDirectory)
		{
			var other = new Path(otherDirectory);
			// if the given non-root is empty, we are looking at a relative path
			if (String.IsNullOrEmpty(other.Info.Root)) 
				return true;

			// they must be on the same drive.
			if (!String.IsNullOrEmpty(chjailedRootPath.Info.DriveLetter) && other.Info.DriveLetter != chjailedRootPath.Info.DriveLetter)
				return false;

			// we do not allow access to directories outside of the specified directory.
			return other.Info.IsParentOf(chjailedRootPath.Info);
		}
Example #2
0
        bool IDirectoryAdapter.Delete(string path, bool recursively)
        {
            AssertAllowed(path);
#if !MONO
            var mTx = CurrentTransaction();
            if (mTx.HasValue)
            {
                return(((IDirectoryAdapter)mTx.Value).Delete(path, recursively));
            }
#endif

            // because of http://stackoverflow.com/questions/3764072/c-win32-how-to-wait-for-a-pending-delete-to-complete

            var target = Path.GetRandomFileName();
            LongPathDirectory.Move(path, target);
            LongPathDirectory.Delete(target, recursively);
            return(true);
        }
		public IDirectory CreateDirectory(Path path)
		{
			throw new System.NotImplementedException();
		}
		public IDirectory GetDirectory(Path directoryPath)
		{
			throw new System.NotImplementedException();
		}
		private static IEnumerable<string> GetFilterPaths(string filter)
		{
			var lastWasSubFolder = false;

			var path = new Path(filter);

			foreach (var segment in path.Segments)
			{
				if (segment == Subfolder)
					if (!lastWasSubFolder)
						lastWasSubFolder = true;
					else
						continue;
				else
					lastWasSubFolder = false;

				yield return segment;
			}
		}