Пример #1
0
 // overridden to set the default encoding to KCODE/BINARY
 protected override int RunFile(string fileName)
 {
     return(RunFile(
                Engine.CreateScriptSourceFromFile(RubyUtils.CanonicalizePath(fileName),
                                                  (((RubyContext)Language).RubyOptions.KCode ?? RubyEncoding.Binary).StrictEncoding)
                ));
 }
Пример #2
0
 private void SetupOptionsForMainFile()
 {
     LanguageSetup.Options["MainFile"]  = RubyUtils.CanonicalizePath(ConsoleOptions.FileName);
     LanguageSetup.Options["Arguments"] = PopRemainingArgs();;
 }
Пример #3
0
 // overridden to set the default encoding to -KX
 protected override int RunFile(string fileName)
 {
     return(RunFile(Engine.CreateScriptSourceFromFile(RubyUtils.CanonicalizePath(fileName), GetSourceCodeEncoding())));
 }
Пример #4
0
 public static MutableString /*!*/ GetCurrentDirectory(RubyClass /*!*/ self)
 {
     return(self.Context.EncodePath(RubyUtils.CanonicalizePath(self.Context.Platform.CurrentDirectory)));
 }
Пример #5
0
        private string /*!*/ CreateCommandLine(CommonProjectNode project, string /*!*/ startupFile, bool debug)
        {
            var commandLine = new StringBuilder();

            bool disableDebugging = project != null && Convert.ToBoolean(project.GetProjectProperty(RubyConstants.ProjectProperties.DisableDebugging, true));

            if (debug && !disableDebugging)
            {
                commandLine.Append(" -D");
            }

            string searchPath = (project != null) ? project.GetProjectProperty(CommonConstants.SearchPath, true) : null;

            if (!String.IsNullOrEmpty(searchPath))
            {
                foreach (string path in searchPath.Split(Path.PathSeparator))
                {
                    try {
                        // the path is relative to the .rbproj file, not to the ir.exe file:
                        var fullPath = RubyUtils.CanonicalizePath(Path.GetFullPath(path));

                        commandLine.Append(" -I");
                        if (fullPath.IndexOf(' ') >= 0)
                        {
                            commandLine.Append('"').Append(fullPath).Append('"');
                        }
                        else
                        {
                            commandLine.Append(path);
                        }
                    } catch {
                        // ignore
                    }
                }
            }

            commandLine.Append(' ').Append('"').Append(startupFile).Append('"');

            string args     = null;
            string launcher = (project != null) ? project.GetProjectProperty(RubyConstants.ProjectProperties.Launcher, true) : null;

            if (launcher == RubyConstants.ProjectProperties.Launcher_Spec)
            {
                string testDir = Path.GetFullPath(Path.Combine(project.GetWorkingDirectory(), "test"));
                if (Directory.Exists(testDir))
                {
                    args = String.Join(" ",
                                       Directory.GetFiles(testDir, "*_spec.rb").ConvertAll((path) => path.IndexOf(' ') >= 0 ? '"' + path + '"' : path)
                                       );
                }
            }
            else
            {
                args = (project != null) ? project.GetProjectProperty(CommonConstants.CommandLineArguments, true) : null;
            }

            if (!String.IsNullOrEmpty(args))
            {
                commandLine.Append(' ');
                commandLine.Append(args);
            }

            return(commandLine.ToString());
        }
Пример #6
0
            internal void DoGlob(string /*!*/ baseDirectory, int position, bool isPreviousDoubleStar)
            {
                if (!_pal.DirectoryExists(baseDirectory))
                {
                    return;
                }

                bool   containsWildcard;
                int    patternEnd        = FindNextSeparator(position, true, out containsWildcard);
                bool   isLastPathSegment = (patternEnd == _pattern.Length);
                string dirSegment        = _pattern.Substring(position, patternEnd - position);

                if (!isLastPathSegment)
                {
                    patternEnd++;
                }

                if (!containsWildcard)
                {
                    string path = baseDirectory + "/" + dirSegment;
                    TestPath(path, patternEnd, isLastPathSegment);
                    return;
                }

                bool doubleStar = dirSegment.Equals("**");

                if (doubleStar && !isPreviousDoubleStar)
                {
                    DoGlob(baseDirectory, patternEnd, true);
                }

                foreach (string file in _pal.GetFileSystemEntries(baseDirectory, "*"))
                {
                    string objectName = Path.GetFileName(file);
                    if (FnMatch(dirSegment, objectName, _flags))
                    {
                        var canon = RubyUtils.CanonicalizePath(file);
                        TestPath(canon, patternEnd, isLastPathSegment);
                        if (doubleStar)
                        {
                            DoGlob(canon, position, true);
                        }
                    }
                }
                if (isLastPathSegment && (_flags & Constants.FNM_DOTMATCH) != 0 || dirSegment[0] == '.')
                {
                    if (FnMatch(dirSegment, ".", _flags))
                    {
                        string directory = baseDirectory + "/.";
                        if (_dirOnly)
                        {
                            directory += '/';
                        }
                        TestPath(directory, patternEnd, true);
                    }
                    if (FnMatch(dirSegment, "..", _flags))
                    {
                        string directory = baseDirectory + "/..";
                        if (_dirOnly)
                        {
                            directory += '/';
                        }
                        TestPath(directory, patternEnd, true);
                    }
                }
            }