All Downloads are FREE. Search and download functionalities are using the official Maven repository.

core.os.MountPointAt Maven / Gradle / Ivy

The newest version!
/*
 * Copyright 2013 Objectos, Fábrica de Software LTDA.
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */
package br.com.objectos.rio.core.os;

import java.io.File;
import java.util.List;

import br.com.objectos.rio.core.main.RioRaw;

import br.com.objectos.way.core.io.Directory;

import com.google.common.base.Strings;
import com.google.common.collect.ImmutableList;

/**
 * @author [email protected] (Marcio Endo)
 */
public class MountPointAt {

  private final Directory dir;

  private List options = ImmutableList.of();
  private String source;
  private String target;

  public MountPointAt(Directory dir) {
    this.dir = dir;
  }

  public MountPoint exec() {
    String point = dir.getAbsolutePath();

    if (!Strings.isNullOrEmpty(target)) {
      File targetFile = dir.fileAt(target);
      point = targetFile.getAbsolutePath();
    }

    RioRaw.INSTANCE.info("mount %s => %s", source, point);

    ProcStdout stdout = Procs.newCommand()
        .add("mount")
        .addAll(options)
        .add(source)
        .add(point)
        .exec();
    return new MountPoint(stdout);
  }

  public MountPointAt options(String... options) {
    this.options = ImmutableList.copyOf(options);
    return this;
  }

  public MountPointAt source(String source) {
    this.source = source;
    return this;
  }

  public MountPointAt target(String target) {
    this.target = target;
    return this;
  }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy