예제 #1
0
파일: Workers.cs 프로젝트: angryzor/DLProg
        public Worker(GUIIface gui, Project p)
        {
            this.p = p;
            Parser = new LuaHTMLParser(gui, p);
            Writer = new FileWriter(p);

            Progress.PropertyChanged += new PropertyChangedEventHandler(Progress_PropertyChanged);
        }
예제 #2
0
 public FileWriter(Project p)
 {
     this.p = p;
 }
예제 #3
0
파일: Context.cs 프로젝트: angryzor/DLProg
        private void SetProject(Project p)
        {
            if (workers != null && workers.IsRunning)
                throw new InvalidOperationException("Cannot load a new project into the program context while the current project is running.");
            if (IsProjectLoaded)
                SaveProject();

            project = p;
            workers = new Workers(project, gui);
            NotifyPropertyChanged("IsProjectLoaded");
            NotifyPropertyChanged("Project");
            NotifyPropertyChanged("Workers");
        }
예제 #4
0
        public LuaHTMLParser(GUIIface gui, Project p)
        {
            this.p = p;
            this.gui = gui;
            /*            string pkgpath = (string)lua["package.path"];
            if (pkgpath == null) pkgpath = "";
            pkgpath += ";" + System.Environment.CurrentDirectory + System.IO.Path.DirectorySeparatorChar + "lualibs" + System.IO.Path.DirectorySeparatorChar + "?.lua";
            lua["package.path"] = pkgpath;
            */
            lua["project"] = new ProjectInterfaceToLua(p);
            lua["queue"] = new QueueInterfaceToLua(p, this);
            lua["util"] = new UtilInterfaceToLua();
            lua.RegisterFunction("log", this, this.GetType().GetMethod("log"));
            lua.RegisterFunction("io.canwrite", this, this.GetType().GetMethod("CanWrite"));
            lua.RegisterFunction("io.ensurefolder", this, this.GetType().GetMethod("EnsureFolder"));
            lua.RegisterFunction("io.movefile", this, this.GetType().GetMethod("MoveFile"));
            lua.DoString(@"
            io.popen = function(prog, mode)
            error('Opening processes is disabled.')
            end
            do
            local realioopen = io.open
            local realioclose = io.close
            local ensurefolder = io.ensurefolder
            local movefile = io.movefile
            io.ensurefolder = nil
            local openfilenames = {}
            io.openfordl = function(filen, mode)
            filen = filen:gsub('/','\\')
            if filen:match('^\\') or filen:match('%.%.\\') or filen:match('^%w:') then
            error('Only relative paths that do not go up (..) are allowed')
            end

            filen = project.DownloadFolder .. '\\' .. filen

            ensurefolder(filen)

            if not io.canwrite(filen) then
            return nil, 'Cannot open file due to user settings.'
            end

            local tmpfilen = filen .. '.dlprog_part'

            local f,err = realioopen(tmpfilen,mode)
            if f then
            openfilenames[f] = filen
            end

            return f,err
            end
            io.open = function(filen, mode)
            filen = filen:gsub('/','\\')
            if filen:match('^\\') or filen:match('%.%.\\') or filen:match('^%w:') then
            error('Only relative paths that do not go up (..) are allowed')
            end

            filen = project.DownloadFolder .. '\\' .. filen

            ensurefolder(filen)

            return realioopen(filen,mode)
            end
            io.close = function(file)
            local ret = realioclose(file)
            local filen = openfilenames[file]

            if filen then
            movefile(filen .. '.dlprog_part',filen)
            openfilenames[file] = nil
            end

            return ret
            end
            end
            ");
        }
예제 #5
0
 public QueueInterfaceToLua(Project p, LuaHTMLParser h)
 {
     this.p = p;
     this.h = h;
 }
예제 #6
0
 public ProjectInterfaceToLua(Project p)
 {
     DownloadFolder = p.RootDirectory;
 }
예제 #7
0
파일: Workers.cs 프로젝트: angryzor/DLProg
 public Workers(Project p, GUIIface gui)
 {
     this.p = p;
     this.gui = gui;
 }