Exemplo n.º 1
0
 public static string GetParentPath(
     string text)
 {
     return(string.IsNullOrEmpty(text)
         ? text
         : ZlpPathHelper.GetFullPath(ZlpPathHelper.Combine(text, @"..")));
 }
Exemplo n.º 2
0
        public ZlpDirectoryInfo CreateSubdirectory(string name)
        {
            var path = ZlpPathHelper.Combine(FullName, name);

            ZlpIOHelper.CreateDirectory(path);
            return(new ZlpDirectoryInfo(path));
        }
 public ZlpFileOrDirectoryInfo Combine(
     string path)
 {
     return
         (new ZlpFileOrDirectoryInfo(
              ZlpPathHelper.Combine(
                  EffectiveDirectory.FullName,
                  path)));
 }
 public ZlpFileOrDirectoryInfo Combine(
     ZlpFileOrDirectoryInfo info)
 {
     return
         (new ZlpFileOrDirectoryInfo(
              ZlpPathHelper.Combine(
                  EffectiveDirectory.FullName,
                  info.FullName)));
 }
 public ZlpFileOrDirectoryInfo Combine(
     ZlpDirectoryInfo info)
 {
     return
         (new ZlpFileOrDirectoryInfo(
              ZlpPathHelper.Combine(
                  EffectiveDirectory.FullName,
                  // According to Reflector, "ToString()" returns the
                  // "OriginalPath". This is what we need here.
                  info.ToString())));
 }
Exemplo n.º 6
0
        public static ZlpDirectoryInfo CombineDirectory(this ZlpDirectoryInfo one, ZlpDirectoryInfo two)
        {
            if (one == null)
            {
                return(two);
            }
            else if (two == null)
            {
                return(one);
            }

            else
            {
                return(new ZlpDirectoryInfo(ZlpPathHelper.Combine(one.FullName, two.FullName)));
            }
        }
Exemplo n.º 7
0
        public static ZlpFileInfo[] GetFiles(string directoryPath, string pattern, SearchOption searchOption)
        {
            directoryPath = CheckAddLongPathPrefix(directoryPath);

            var results = new List <ZlpFileInfo>();

            PInvokeHelper.WIN32_FIND_DATA findData;
            var findHandle = PInvokeHelper.FindFirstFile(directoryPath.TrimEnd('\\') + "\\" + pattern, out findData);

            if (findHandle != PInvokeHelper.INVALID_HANDLE_VALUE)
            {
                try
                {
                    bool found;
                    do
                    {
                        var currentFileName = findData.cFileName;

                        // if this is a file, find its contents
                        if (((int)findData.dwFileAttributes & PInvokeHelper.FILE_ATTRIBUTE_DIRECTORY) == 0)
                        {
                            results.Add(new ZlpFileInfo(ZlpPathHelper.Combine(directoryPath, currentFileName)));
                        }

                        // find next
                        found = PInvokeHelper.FindNextFile(findHandle, out findData);
                    } while (found);
                }
                finally
                {
                    // close the find handle
                    PInvokeHelper.FindClose(findHandle);
                }
            }

            if (searchOption == SearchOption.AllDirectories)
            {
                foreach (var dir in GetDirectories(directoryPath))
                {
                    results.AddRange(GetFiles(dir.FullName, pattern, searchOption));
                }
            }

            return(results.ToArray());
        }
Exemplo n.º 8
0
        public static ZlpFileInfo CombineFile(/*this*/ string one, string two)
        {
            if (one == null && two == null)
            {
                return(null);
            }
            else if (two == null)
            {
                return(null);
            }
            else if (one == null)
            {
                return(new ZlpFileInfo(two));
            }

            else
            {
                return(new ZlpFileInfo(ZlpPathHelper.Combine(one, two)));
            }
        }
Exemplo n.º 9
0
        public static ZlpFileInfo CombineFile(this ZlpDirectoryInfo one, string two)
        {
            if (one == null && two == null)
            {
                return(null);
            }
            else if (two == null)
            {
                return(null);
            }
            else if (one == null)
            {
                return(new ZlpFileInfo(two));
            }

            else
            {
                return(new ZlpFileInfo(ZlpPathHelper.Combine(one.FullName, two)));
            }
        }
Exemplo n.º 10
0
        public static ZlpDirectoryInfo[] GetDirectories(string directoryPath, string pattern)
        {
            directoryPath = CheckAddLongPathPrefix(directoryPath);

            var results = new List <ZlpDirectoryInfo>();

            PInvokeHelper.WIN32_FIND_DATA findData;
            var findHandle = PInvokeHelper.FindFirstFile(directoryPath.TrimEnd('\\') + @"\" + pattern, out findData);

            if (findHandle != PInvokeHelper.INVALID_HANDLE_VALUE)
            {
                try
                {
                    bool found;
                    do
                    {
                        var currentFileName = findData.cFileName;

                        // if this is a directory, find its contents
                        if (((int)findData.dwFileAttributes & PInvokeHelper.FILE_ATTRIBUTE_DIRECTORY) != 0)
                        {
                            if (currentFileName != @"." && currentFileName != @"..")
                            {
                                results.Add(new ZlpDirectoryInfo(ZlpPathHelper.Combine(directoryPath, currentFileName)));
                            }
                        }

                        // find next
                        found = PInvokeHelper.FindNextFile(findHandle, out findData);
                    } while (found);
                }
                finally
                {
                    // close the find handle
                    PInvokeHelper.FindClose(findHandle);
                }
            }

            return(results.ToArray());
        }