001/*
002 * To change this template, choose Tools | Templates
003 * and open the template in the editor.
004 */
005package org.anarres.qemu.exec.host.chardev;
006
007import java.io.File;
008import java.util.Map;
009
010/**
011 *
012 * @author shevek
013 */
014public class UnixCharDevice extends AbstractSocketCharDevice {
015
016    private final File file;
017
018    public UnixCharDevice(File file, boolean server, boolean nowait) {
019        super("socket", server, nowait);
020        this.file = file;
021    }
022
023    public UnixCharDevice(String file) {
024        this(new File(file), true, true);
025    }
026
027    @Override
028    protected void addProperties(Map<String, Object> m) {
029        super.addProperties(m);
030        m.put("path", file.getAbsolutePath());
031    }
032
033    @Override
034    public String toString() {
035        StringBuilder buf = new StringBuilder("unix:");
036        buf.append(file.getAbsolutePath());
037        if (server)
038            buf.append(",server");
039        if (nowait)
040            buf.append(",nowait");
041        return buf.toString();
042    }
043}