Esempio n. 1
0
		public virtual void Init() {

			_baseDirectory = Path.GetFullPath(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "..\\.."));
			_paths = new PathUtility();
			_win32 = new Win32IO();
			_scanner = new FileSystemScanner(_paths, _win32);
		}
Esempio n. 2
0
        /// <summary>
        /// Determines whether the specified path is a Asset path relative to the project folder.
        /// </summary>
        /// <param name="path">The path.</param>
        /// <returns><c>true</c> if [is asset path] [the specified path]; otherwise, <c>false</c>.</returns>
        /// <exception cref="ArgumentNullException">path</exception>
        public static bool IsAssetPath(string path)
        {
            if (string.IsNullOrEmpty(path))
            {
                throw new ArgumentNullException(nameof(path));
            }

            var newPath = ReSharpPathUtility.UnifyToAltDirectorySeparatorChar(path);

            return(newPath.StartsWith(EditorEnvironment.AssetsFolderName + Path.AltDirectorySeparatorChar) || newPath.StartsWith(ReSharpPathUtility.UnifyToAltDirectorySeparatorChar(Directory.GetCurrentDirectory())));
        }
Esempio n. 3
0
        /// <summary>
        /// Converts to absolute path.
        /// </summary>
        /// <param name="paths">An array of parts of the path.</param>
        /// <returns>The absolute path of the asset path.</returns>
        /// <exception cref="ArgumentNullException">path</exception>
        public static string ConvertToAbsolutePath(params string[] paths)
        {
            if (paths == null)
            {
                throw new ArgumentNullException(nameof(paths));
            }

            var newPaths = new string[paths.Length + 1];

            newPaths[0] = Directory.GetCurrentDirectory();
            paths.CopyTo(newPaths, 1);
            return(ReSharpPathUtility.UnifyToAltDirectorySeparatorChar(Path.Combine(newPaths)));
        }
Esempio n. 4
0
        /// <summary>
        /// Converts absolute path to the path relative to the project folder.
        /// </summary>
        /// <param name="path">The path need to be converted.</param>
        /// <returns>The asset path to the project.</returns>
        /// <exception cref="ArgumentNullException">path</exception>
        public static string ConvertToAssetPath(string path)
        {
            if (string.IsNullOrEmpty(path))
            {
                throw new ArgumentNullException(nameof(path));
            }

            var currentDirectory = ReSharpPathUtility.UnifyToAltDirectorySeparatorChar(Directory.GetCurrentDirectory());
            var absolutePath     = ReSharpPathUtility.UnifyToAltDirectorySeparatorChar(path);

            return(absolutePath.KmpIndexOf(currentDirectory) != -1
                ? ReSharpPathUtility.UnifyToAltDirectorySeparatorChar(absolutePath.Substring(currentDirectory.Length + 1))
                : path);
        }