Beispiel #1
0
        private bool IsFileLoaded(string /*!*/ path, string /*!*/ fullPath, IEnumerable <string> appendExtensions)
        {
            var toPath          = _toStrStorage.GetSite(CompositeConversionAction.Make(_context, CompositeConversion.ToPathToStr));
            var encodedPath     = _context.EncodePath(path);
            var encodedFullPath = (fullPath != null) ? _context.EncodePath(fullPath) : null;

            foreach (object file in GetLoadedFiles())
            {
                if (file == null)
                {
                    throw RubyExceptions.CreateTypeConversionError("nil", "String");
                }

                // use case sensitive comparison
                MutableString loadedFile = Protocols.CastToPath(toPath, file);
                if (loadedFile.Equals(encodedPath) || loadedFile.Equals(encodedFullPath))
                {
                    return(true);
                }

                if (appendExtensions != null)
                {
                    foreach (var extension in appendExtensions)
                    {
                        var pathWithExtension = _context.EncodePath(path + extension);
                        if (loadedFile.Equals(pathWithExtension) || loadedFile.Equals(encodedFullPath))
                        {
                            return(true);
                        }
                    }
                }
            }

            return(false);
        }
Beispiel #2
0
        internal string[] /*!*/ GetLoadPathStrings()
        {
            var loadPaths = GetLoadPaths();
            var result    = new string[loadPaths.Length];
            var toPath    = _toStrStorage.GetSite(CompositeConversionAction.Make(_context, CompositeConversion.ToPathToStr));

            for (int i = 0; i < loadPaths.Length; i++)
            {
                if (loadPaths[i] == null)
                {
                    throw RubyExceptions.CreateTypeConversionError("nil", "String");
                }

                result[i] = Protocols.CastToPath(toPath, loadPaths[i]).ConvertToString();
            }

            return(result);
        }
Beispiel #3
0
        private bool AnyFileLoaded(IEnumerable <MutableString> /*!*/ paths)
        {
            var toPath = _toStrStorage.GetSite(CompositeConversionAction.Make(_context, CompositeConversion.ToPathToStr));

            foreach (object file in GetLoadedFiles())
            {
                if (file == null)
                {
                    throw RubyExceptions.CreateTypeConversionError("nil", "String");
                }

                // use case sensitive comparison
                MutableString loadedPath = Protocols.CastToPath(toPath, file);
                if (paths.Any((path) => loadedPath.Equals(path)))
                {
                    return(true);
                }
            }

            return(false);
        }