예제 #1
0
파일: AFPServ.cs 프로젝트: windrobin/kumpro
        public static void CreateDir(IDir self, String unixPath) {
            if (unixPath == null) return; // Already exists
            if (unixPath.StartsWith("/")) {
                CreateDir(GetRoot(self), unixPath.Substring(1));
                return;
            }
            int p = unixPath.IndexOf('/');
            String s1 = (p < 0) ? unixPath : unixPath.Substring(0, p);
            String s2 = (p < 0) ? null : unixPath.Substring(1 + p);
            if (s1 == ".") {
                CreateDir(self, s2);
                return;
            }
            if (s1 == "..") {
                CreateDir(self.ParentDir, s2);
                return;
            }
            for (int t = 0; t < 2; t++) {
                IEnt o = self.FindReal(s1);
                if (o is IDir) {
                    CreateDir((IDir)o, s2);
                    return;
                }
                else if (o != null) {
                    throw new MkdException("We knew \"" + o.Name + "\" is a file.");
                }

                self.CreateDirHere(s1);

                if (s2 == null) return;
            }
            throw new MkdException("We can't create \"" + unixPath + "\".");
        }