Skip to content

Commit

Permalink
action/force_prl_fs_mount: Added hostpath ensurance & conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
legal90 committed Mar 23, 2014
1 parent 09630a9 commit 9911183
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions lib/vagrant-parallels/action/force_prl_fs_mount.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
require "log4r"
require 'vagrant/util/platform'

module VagrantPlugins
module Parallels
module Action
Expand All @@ -9,12 +12,36 @@ class ForcePrlFsMount

def initialize(app, env)
@app = app
@logger = Log4r::Logger.new("vagrant::plugins::parallels::force_prl_fs_mount")
end

def call(env)
# Only for Linux guests!
if env[:machine].communicate.test("uname -s | grep 'Linux'")
folders = synced_folders(env[:machine])[:parallels]

# Go through each folder and make sure to create it if
# it does not exist on host
folders.each do |id, data|
data[:hostpath] = File.expand_path(data[:hostpath], env[:root_path])

# Create the hostpath if it doesn't exist and we've been told to
if !File.directory?(data[:hostpath]) && data[:create]
@logger.info("Creating shared folder host directory: #{data[:hostpath]}")
begin
Pathname.new(data[:hostpath]).mkpath
rescue Errno::EACCES
raise Vagrant::Errors::SharedFolderCreateFailed,
path: data[:hostpath]
end
end

if File.directory?(data[:hostpath])
data[:hostpath] = File.realpath(data[:hostpath])
data[:hostpath] = Vagrant::Util::Platform.fs_real_path(data[:hostpath]).to_s
end
end

opts = nil
instance = VagrantPlugins::Parallels::SyncedFolder.new
instance.enable(env[:machine], folders, opts)
Expand Down

0 comments on commit 9911183

Please sign in to comment.