diff options
Diffstat (limited to 'lib/sisu/v0/sysenv.rb')
-rw-r--r-- | lib/sisu/v0/sysenv.rb | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/lib/sisu/v0/sysenv.rb b/lib/sisu/v0/sysenv.rb index 329c9111..95830224 100644 --- a/lib/sisu/v0/sysenv.rb +++ b/lib/sisu/v0/sysenv.rb @@ -487,9 +487,10 @@ module SiSU_Env end def file_encoding(filename,cmd='') #file encoding program='file' + fnsp=Info_env.new(filename).source_file_with_path if program_found?(program) - encoding=%x{file #{filename}}.strip - encoding.gsub!(/#{filename}:(\s+|$)/,'') + encoding=%x{file #{fnsp}}.strip + encoding.gsub!(/#{fnsp}:(\s+|$)/,'') encoding=if encoding and not encoding.empty?; encoding else 'UTF-8 assumed, encoding undetermined' end @@ -1084,6 +1085,22 @@ WOK end self end + def source_file_path + file=@fns.gsub(/(\.ssm)/,'._sst') + pth=unless file =~/\._sst$/; "#{Dir.pwd}" + else "#{path.composite_file}" + end + end + def source_file_with_path + file=@fns.gsub(/(\.ssm)/,'._sst') + "#{source_file_path}/#{file}" + end + def read_source_file(fns) + fns_array=unless fns =~/\._sst$/ + IO.readlines(fns,'') + else IO.readlines("#{path.composite_file}/#{fns}",'') + end + end def path #dir def home @sys.home @@ -1216,6 +1233,11 @@ WOK end @processing end + def composite_file + pth=path.dal #"#{processing}/composite" + File.mkpath(pth) unless FileTest.directory?(pth) + pth + end def dal pth=if defined? @rc['processing']['dal']; "#{processing}/#{@rc['processing']['dal']}" else "#{processing}/#{defaults[:processing_dal]}" @@ -1976,7 +1998,7 @@ WOK def remote_host_base remote=remote_host_base_general #host_ip=IPSocket.getaddress(remote[:host]) unless remote[:host].empty? - @@flag_remote=true if remote[:name] =~/\S+@\S+/ #and host_ip =~/\d+\.\d+\.\d+\.\d+/ #very naive check should be enough /[0-255]+\.[0-255]+\.[0-255]+\.[0-255]+/ + @@flag_remote=true if remote[:name] =~/\S+?@\S+/ #and host_ip =~/\d+\.\d+\.\d+\.\d+/ #very naive check should be enough /[0-255]+\.[0-255]+\.[0-255]+\.[0-255]+/ remote_host_base_general[:name] end def scp #sort out later using ruby libraries #not ideal, first time each file is sent, -r must be called separately for subdir to be built |