Class: Yast::DirectoryClass

Inherits:
Module
  • Object
show all
Defined in:
library/general/src/modules/Directory.rb

Instance Method Summary collapse

Instance Method Details

#DirectoryObject

Constructor



113
114
115
116
117
# File 'library/general/src/modules/Directory.rb', line 113

def Directory
  ResetTmpDir()

  nil
end

#find_data_file(relative_path) ⇒ String

Find an existing file in any of the YaST data directories

Parameters:

  • relative_path (String)

    name of the file to find

Returns:

  • (String)

    full path of the file if it's found, nil otherwise



123
124
125
126
# File 'library/general/src/modules/Directory.rb', line 123

def find_data_file(relative_path)
  possible_paths = Yast.y2paths.map { |p| File.join(p, "data", relative_path) }
  possible_paths.find { |p| File.exist?(p) }
end

#mainObject



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# File 'library/general/src/modules/Directory.rb', line 32

def main
  textdomain "base"

  @yast2dir = "/usr/share/YaST2"
  @execcompdir = "/usr/lib/YaST2"

  # Directory for binaries and scripts
  @bindir = "/usr/lib/YaST2/bin"
  @ybindir = @bindir

  # Directory for log files
  @logdir = "/var/log/YaST2"

  # Directory for variable data
  @vardir = "/var/lib/YaST2"

  # Directory for configuration data
  @etcdir = "/etc/YaST2"

  # Directory with agents
  @agentdir = Ops.add(@execcompdir, "/servers_non_y2")

  # Directory for data
  # @deprecated since it does not honor Y2DIR. Use #find_data_file instead
  @datadir = Ops.add(@yast2dir, "/data")
  @ydatadir = @datadir

  # Directory for schema (RNC,DTD,RNG)
  @schemadir = Ops.add(@yast2dir, "/schema")

  # Directory for includes
  @includedir = Ops.add(@yast2dir, "/include")
  @yncludedir = @includedir

  # Directory for images
  @imagedir = Ops.add(@yast2dir, "/images")

  # Directory for themes
  @themedir = Ops.add(@yast2dir, "/theme")

  # Directory for locales
  @localedir = Ops.add(@yast2dir, "/locale")

  # Directory for clients
  @clientdir = Ops.add(@yast2dir, "/clients")

  # Directory for modules
  @moduledir = Ops.add(@yast2dir, "/modules")

  # Directory for SCR definition files
  @scrconfdir = Ops.add(@yast2dir, "/scrconf")

  # Directory for desktop files
  @desktopdir = "/usr/share/applications/YaST2"

  # Base directory for icons
  #
  @icondir = Ops.add(@themedir, "/current/icons/")

  # Directory for temporary files
  # Must be updated with ResetTmpDir() call after the SCR change!
  @tmpdir = "/tmp"

  # Directory needed for custom installation workflows
  # It can be set to the path containing additional file on a CDROM
  @custom_workflow_dir = ""
  Directory()
end

#ResetTmpDirObject

Set temporary directory



102
103
104
105
106
107
108
109
110
# File 'library/general/src/modules/Directory.rb', line 102

def ResetTmpDir
  @tmpdir = Convert.to_string(SCR.Read(path(".target.tmpdir")))
  if @tmpdir == "" || @tmpdir.nil?
    Builtins.y2error("Failed to set temporary directory: %1", @tmpdir)
    @tmpdir = "/tmp"
  end

  nil
end