NamedPipeInputStream.java
     1: //========================================================================================
     2: //  NamedPipeInputStream.java
     3: //    en:Input from named pipe
     4: //    ja:名前付きパイプから入力します
     5: //  Copyright (C) 2003-2022 Makoto Kamada
     6: //
     7: //  This file is part of the XEiJ (X68000 Emulator in Java).
     8: //  You can use, modify and redistribute the XEiJ if the conditions are met.
     9: //  Read the XEiJ License for more details.
    10: //  https://stdkmd.net/xeij/
    11: //========================================================================================
    12: 
    13: package xeij;
    14: 
    15: import java.io.*;
    16: 
    17: public abstract class NamedPipeInputStream extends InputStream {
    18: 
    19:   public static NamedPipeInputStream createInputStream (String name) throws IOException {
    20:     if (XEiJ.prgWindllLoaded) {
    21:       return new NamedPipeInputStream.Win (name);
    22:     }
    23:     throw new IOException ("Unsupported operating system");
    24:   }
    25: 
    26:   public abstract void cancel () throws IOException;
    27:   public abstract void connect () throws IOException;
    28: 
    29:   protected static class Win extends NamedPipeInputStream {
    30:     private long wp;
    31:     public Win (String name) throws IOException {
    32:       open (name);
    33:     }
    34:     @Override public native int available () throws IOException;
    35:     @Override public native void cancel () throws IOException;
    36:     @Override public native void close () throws IOException;
    37:     @Override public native void connect () throws IOException;
    38:     public native void open (String name) throws IOException;
    39:     @Override public native int read () throws IOException;
    40:     @Override public native int read (byte[] b) throws IOException;
    41:     @Override public native int read (byte[] b, int off, int len) throws IOException;
    42:     @Override public native int readNBytes (byte[] b, int off, int len) throws IOException;
    43:   }
    44: 
    45: }