Ejemplo n.º 1
0
Archivo: Dir.cs Proyecto: ltwlf/IronSP
        public static MutableString Read(RubyContext /*!*/ context, RubyDir /*!*/ self)
        {
            self.ThrowIfClosed();

            if (self._pos + 1 > self._rawEntries.Length)
            {
                return(null);
            }

            MutableString ret;

            if (self._pos == -2)
            {
                ret = context.EncodePath(".");
            }
            else if (self._pos == -1)
            {
                ret = context.EncodePath("..");
            }
            else
            {
                ret = context.EncodePath(context.Platform.GetFileName(self._rawEntries[self._pos]));
            }
            self._pos++;
            return(ret);
        }
Ejemplo n.º 2
0
        private RubyArray /*!*/ MakeLoadPaths(RubyOptions /*!*/ options)
        {
            var loadPaths = new RubyArray();

            if (options.HasSearchPaths)
            {
                foreach (string path in options.SearchPaths)
                {
                    loadPaths.Add(_context.EncodePath(path));
                }
            }

#if !SILVERLIGHT // no library paths on Silverlight
            string applicationBaseDir;
            try {
                applicationBaseDir = AppDomain.CurrentDomain.BaseDirectory;
            } catch (SecurityException) {
                applicationBaseDir = null;
            }

            AddAbsoluteLibraryPaths(loadPaths, applicationBaseDir, options.LibraryPaths);
#endif
            loadPaths.Add(MutableString.CreateAscii("."));
            return(loadPaths);
        }
Ejemplo n.º 3
0
Archivo: Dir.cs Proyecto: ltwlf/IronSP
        private RubyArray /*!*/ GetEntries(RubyContext /*!*/ context)
        {
            ThrowIfClosed();

            RubyArray ret = new RubyArray(_rawEntries.Length + 2);

            ret.Add(context.EncodePath("."));
            ret.Add(context.EncodePath(".."));
            foreach (string entry in _rawEntries)
            {
                var encoded = context.TryEncodePath(context.Platform.GetFileName(entry));
                if (encoded != null)
                {
                    ret.Add(encoded);
                }
            }
            return(ret);
        }
Ejemplo n.º 4
0
Archivo: Glob.cs Proyecto: ltwlf/IronSP
        public static IEnumerable <MutableString> /*!*/ GetMatches(RubyContext /*!*/ context, MutableString /*!*/ pattern, int flags)
        {
            string strPattern = context.DecodePath(pattern);

            foreach (string strFileName in GetMatches(context.Platform, strPattern, flags))
            {
                yield return(context.EncodePath(strFileName).TaintBy(pattern));
            }
        }
Ejemplo n.º 5
0
        private RubyArray/*!*/ GetEntries(RubyContext/*!*/ context) {
            ThrowIfClosed();

            RubyArray ret = new RubyArray(_rawEntries.Length + 2);
            ret.Add(context.EncodePath("."));
            ret.Add(context.EncodePath(".."));
            foreach (string entry in _rawEntries) {
                var encoded = context.TryEncodePath(context.Platform.GetFileName(entry));
                if (encoded != null) {
                    ret.Add(encoded);
                }
            }
            return ret;
        }
Ejemplo n.º 6
0
        public static MutableString Read(RubyContext/*!*/ context, RubyDir/*!*/ self) {
            self.ThrowIfClosed();

            if (self._pos + 1 > self._rawEntries.Length) {
                return null;
            }

            MutableString ret;
            if (self._pos == -2) {
                ret = context.EncodePath(".");
            } else if (self._pos == -1) {
                ret = context.EncodePath("..");
            } else {
                ret = context.EncodePath(context.Platform.GetFileName(self._rawEntries[self._pos]));
            }
            self._pos++;
            return ret;
        }
Ejemplo n.º 7
0
        private RubyArray /*!*/ MakeLoadPaths(RubyOptions /*!*/ options)
        {
            var loadPaths = new RubyArray();

            if (options.HasSearchPaths)
            {
                foreach (string path in options.SearchPaths)
                {
                    loadPaths.Add(_context.EncodePath(path));
                }
            }

            AddStandardLibraryPath(loadPaths, options.StandardLibraryPath, options.ApplicationBase);
            // TODO: remove?
            loadPaths.Add(MutableString.CreateAscii("."));
            return(loadPaths);
        }
Ejemplo n.º 8
0
 private bool RequireFile(string /*!*/ path, Scope scope)
 {
     return(_context.Loader.LoadFile(scope, null, _context.EncodePath(path), LoadFlags.Require));
 }
Ejemplo n.º 9
0
 public static IEnumerable<MutableString>/*!*/ GetMatches(RubyContext/*!*/ context, MutableString/*!*/ pattern, int flags) {
     string strPattern = context.DecodePath(pattern);
     foreach (string strFileName in GetMatches(context.Platform, strPattern, flags)) {
         yield return context.EncodePath(strFileName).TaintBy(pattern);
     }
 }