public override INode DoCreate(bool createParent)
        {
            if (!createParent)
            {
                if (!this.Address.IsRoot && !ParentDirectory.Exists)
                {
                    throw new IOException();
                }

                // Mono crashes with ** ERROR **: file object.c: line 1301 (mono_object_get_virtual_method): assertion failed: (res)
                // DictionaryBasedNodeAttributes attribs = this.Attributes;

                var attribs = ((DictionaryBasedNodeAttributes)base.Attributes);

                using (attribs.GetAutoLock().Lock())
                {
                    attribs.SetValue <bool>("Exists", true);
                }

                return(this);
            }

            if (!this.Address.IsRoot && !ParentDirectory.Exists)
            {
                ParentDirectory.Create(true);
            }

            this.Attributes.SetValue <bool>("Exists", true);

            ((ImaginaryDirectory)ParentDirectory).Add(this);

            return(this);
        }
示例#2
0
        /// <summary>
        /// Tries to get the path to a directory, recursively adding all the directories above it if necessary
        /// </summary>
        /// <param name="Info">Info for the directory to find</param>
        /// <param name="Result">On success, receives the directory</param>
        /// <returns>True if the directory exists</returns>
        static bool TryGetDirectoryInternal(DirectoryInfo Info, out WorkspaceDirectory Result)
        {
            DirectoryInfo ParentInfo = Info.Parent;

            if (ParentInfo == null)
            {
                // Try to find an existing root directory that matches this directory, or add a new one
                DirectoryReference Location = new DirectoryReference(Info);
                if (!RootDirectories.TryGetValue(Location, out Result))
                {
                    Result = RootDirectories.GetOrAdd(Location, new WorkspaceDirectory(Info));
                }
                return(true);
            }
            else
            {
                // Get the parent directory
                WorkspaceDirectory ParentDirectory;
                if (!TryGetDirectoryInternal(ParentInfo, out ParentDirectory))
                {
                    Result = null;
                    return(false);
                }

                // Look for a directory within this directory
                return(ParentDirectory.TryGetDirectory(Info.Name, out Result));
            }
        }
示例#3
0
        public ActionResult DeleteConfirmed(int id)
        {
            ParentDirectory parentDirectory = db.ParentDirectories.Find(id);

            db.ParentDirectories.Remove(parentDirectory);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
示例#4
0
 public void ClearPermission()
 {
     if (ParentDirectory == this)
     {
         return;
     }
     ParentDirectory.ClearPermission();
     this.Permission = ParentDirectory.Permission;
 }
        public void Rename(string newName)
        {
            string newPath = (HasParentDirectory ? ParentDirectory.GetPathWithSeparator() + newName : newName);

            System.IO.Directory.Move(Path, newPath);

            // Update Directory info
            UpdateInfoFrom(FromPath(newPath));
        }
示例#6
0
 private void BuildPathRecursive(StringBuilder stringBuilder)
 {
     if (ParentDirectory != null)
     {
         ParentDirectory.BuildPathRecursive(stringBuilder);
         stringBuilder.Append('/');
     }
     stringBuilder.Append(Name);
 }
示例#7
0
文件: VFile.cs 项目: trei1205/UniFTP
 public void ClearPermission()
 {
     if (ParentDirectory.VirtualPath == "/")
     {
         return;
     }
     ParentDirectory.ClearPermission();
     this.Permission = ParentDirectory.Permission;
 }
示例#8
0
 public ActionResult Edit([Bind(Include = "ID,Name,Address,Email,PhoneNum,CreateDate")] ParentDirectory parentDirectory)
 {
     if (ModelState.IsValid)
     {
         db.Entry(parentDirectory).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(parentDirectory));
 }
示例#9
0
        /// <summary>
        /// Create the file if it does not already exist.
        /// </summary>
        public void Create()
        {
            if (!Exists)
            {
                // This will recursively create parent directory if any of them not existed.
                ParentDirectory.Create();

                System.IO.File.Create(Path).Dispose();
            }
        }
示例#10
0
        public string GetPath()
        {
            string directoryPath = ParentDirectory == null ? null : ParentDirectory.GetPath();

            if (String.IsNullOrEmpty(directoryPath))
            {
                return(Name);
            }
            return(directoryPath + "/" + Name);
        }
示例#11
0
        public ActionResult Create([Bind(Include = "ID,Name,Address,Email,PhoneNum,CreateDate")] ParentDirectory parentDirectory)
        {
            if (ModelState.IsValid)
            {
                db.ParentDirectories.Add(parentDirectory);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(parentDirectory));
        }
示例#12
0
        // GET: ParentDirectories/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ParentDirectory parentDirectory = db.ParentDirectories.Find(id);

            if (parentDirectory == null)
            {
                return(HttpNotFound());
            }
            return(View(parentDirectory));
        }
        protected override void CleanupInternal()
        {
            if (Token != null)
            {
                if (UploadHandler.GetTransferStatus(Token.TransferId) != TransferStatus.UnknownTransfer)
                {
                    UploadHandler.CancelTransfer(Token.TransferId, AbortReason.Undefined);
                }
            }

            SystemTime.Reset();
            ParentDirectory.Delete(true);

            base.CleanupInternal();
        }
示例#14
0
 private void OnEndEditName()
 {
     if (EditName != Name)
     {
         if (CAssetRegistry.Instance.RenameFolder(Path, EditName))
         {
             Name = EditName;
             ParentDirectory?.UpdateSubDirectories();
         }
         else
         {
             EditName = Name;
         }
     }
 }
示例#15
0
        public DirectoryInfo[] SearchParrentDirectory()//Return array Parent directory at devise
        {
            DirectoryInfo[] dire = new DirectoryInfo[0];

            foreach (DriveInfo n in DriveInfo.GetDrives())                                            //Return all drive
            {
                if (n.IsReady)
                {
                    if (n.TotalSize != 0)                                     //if TotalSize is do not equals zero
                    {
                        Array.Resize(ref dire, dire.Length + 1);
                        dire[dire.Length - 1] = new DirectoryInfo(n.Name);
                    }
                }
            }
            for (int i = 0; i < dire.Length; i++)
            {
                dire[i] = dire[i].Root;                                       //Root directory for drive
                // while (dire[i].Parent != null)
                // {
                //     dire[i] = dire[i].Parent;

                // }
            }
            ParentDirectory <DirectoryInfo> par = new ParentDirectory <DirectoryInfo>();

            dire = par.ParDire(dire, new EquateI());                                                        //remove and root directory from the array if there is one similar to it
            DriveInfo[] drive = new DriveInfo[dire.Length];
            foreach (DirectoryInfo dir in par.ParDire(dire, new EquateI()))
            {
                int i = 0;
                drive[i] = new DriveInfo(dir.Name);
                i++;
            }
            Sort <DriveInfo> sort = new Sort <DriveInfo>();                                                   //Fast sort(TotalSize)

            drive = sort.FastSort(drive, new Comparison());
            dire  = new DirectoryInfo[0];
            foreach (DriveInfo n in drive)
            {
                Array.Resize(ref dire, dire.Length + 1);
                dire[dire.Length - 1] = new DirectoryInfo(n.Name);
            }
            return(dire);
        }
示例#16
0
        public void Delete()
        {
            // Ensure that this file/directory and all children are writable
            MakeWritable(true);

            // Also ensure the directory containing this file/directory is writable,
            // otherwise we will not be able to delete it
            ParentDirectory.MakeWritable(false);

            if (Directory.Exists(this))
            {
                Directory.Delete(this, true);
            }
            else if (File.Exists(this))
            {
                File.Delete(this);
            }
        }
示例#17
0
        /// <summary>
        /// Adds a new project based on the supplied template file
        /// </summary>
        /// <param name="projectName"></param>
        /// <param name="templateFile"></param>
        public SolutionProject AddProjectFromTemplate(string projectName, string templateFile)
        {
            var existing = FindProject(projectName);

            if (existing != null)
            {
                ThrowExceptions.ArgumentOutOfRangeException(Exc.GetStackTrace(), type, Exc.CallingMethod(), "projectName", "Project with this name ({0}) already exists in the solution".ToFormat(projectName));
            }


            var project    = MSBuildProject.CreateFromFile(projectName, templateFile);
            var csProjFile = new CsProjFile(ParentDirectory.AppendPath(projectName, projectName + ".csproj"), project);

            csProjFile.ProjectGuid = Guid.NewGuid();

            var reference = new SolutionProject(csProjFile, ParentDirectory);

            _projects.Add(reference);

            return(reference);
        }
示例#18
0
 /// <summary>
 /// Moves the Directory to a new Directory.
 /// </summary>
 /// <returns>The Directory to move to.</returns>
 /// <param name="to">The moved Directory.</param>
 public Directory MoveTo(Directory to) => ParentDirectory.MoveDirectory(this, to);
示例#19
0
 public FilePath ChangeName(string newName)
 {
     return(ParentDirectory.Combine(newName) + Extension);
 }
示例#20
0
        public void Requesting_For_Token_Should_Be_Denied()
        {
            var subDir = ParentDirectory.CreateSubdirectory("SomeFolder");

            UploadHandler.RequestUploadToken(subDir.FullName, true, SourceFilePath.Length, "bin");
        }