Ee0505bbd355292778077fb662c88f13

This method sends a command an a other process which i cant control (@director.send_command). This other process needs some time and creates a file when it is finished. So i check in a loop if the file are avaiable and wait another second to give the other process time to actually write the file. This is a bad solution and I search for a solution to check if the other process is finish writing the file.

def init_scite_buffer
        # Check for allready opened files
        res = @director.send_command('savesession', '/tmp/SciTE.session', false)
        until File.exists?('/tmp/SciTE.session')
            sleep 0.1
        end
        # We have to wait until the file is written
        sleep 1 # baaaaad :(
        fh = File.new('/tmp/SciTE.session', 'r+')
        fh.readlines.join("\n").grep(/path=/) {|line|
            p line.split("path=/")[1].chomp
            @observer.update('opened:/' + line.split("path=/")[1].strip)
        }
        
        fh.close
        until fh.closed?
            sleep 0.1
        end
        File.delete('/tmp/SciTE.session') if File.exists?('/tmp/SciTE.session')
    end

Refactorings

No refactoring yet !

Your refactoring





Format Copy from initial code

or Cancel