Tabnine Logo
PortableFileSystem
Code IndexAdd Tabnine to your IDE (free)

How to use
PortableFileSystem
in
org.kframework.krun.ioserver.filesystem.portable

Best Java code snippets using org.kframework.krun.ioserver.filesystem.portable.PortableFileSystem (Showing top 18 results out of 315)

origin: kframework/k

  static void processIOException(IOException e) throws IOException {
    if (e instanceof EOFException) {
      throw new IOException("EOF");
    }
    processErrno(e.getMessage(), e);
  }
}
origin: kframework/k

public long tell() throws IOException {
  try {
    return raf.getFilePointer();
  } catch (IOException e) {
    PortableFileSystem.processIOException(e);
    throw e; //unreachable
  }
}
origin: kframework/k

@Test
public void testReadFile() throws Exception {
  when(files.resolveWorkingDirectory(Matchers.anyString())).thenAnswer(new Answer<java.io.File>() {
    @Override
    public java.io.File answer(InvocationOnMock invocation)
        throws Throwable {
      return new java.io.File((String)invocation.getArguments()[0]);
    }
  });
  PortableFileSystem fs = new PortableFileSystem(kem, files);
  long fd = fs.open(new java.io.File(getClass().getResource("/fs-test.txt").toURI()).getAbsolutePath(), "r");
  File f = fs.get(fd);
  byte[] file = "foo\n".getBytes(Charset.forName("ASCII"));
  Assert.assertArrayEquals(file, f.read(4));
  try {
    f.read(1);
    Assert.fail();
  } catch (IOException e) {
    Assert.assertEquals("EOF", e.getMessage());
  }
}
origin: kframework/k

public void close(long fd) throws IOException {
  File f = get(fd);
  assert f instanceof org.kframework.krun.ioserver.filesystem.portable.File;
  ((org.kframework.krun.ioserver.filesystem.portable.File)f).close();
  files.remove(descriptors.get(fd));
  descriptors.remove(fd);
}
origin: kframework/k

} catch (FileNotFoundException e) {
  try {
    processFileNotFoundException(e);
  } catch (IOException ioe) {
    if (ioe.getMessage().equals("EISDIR") && mode.equals("r")) {
origin: kframework/k

public void write(byte[] b) throws IOException {
  try {
    raf.write(b);
  } catch (IOException e) {
    PortableFileSystem.processIOException(e);
  }
}
origin: kframework/k

static void processFileNotFoundException(FileNotFoundException e) throws IOException {
  String message = e.getMessage();
  int startIdx = message.lastIndexOf("(") + 1;
  int endIdx = message.length() - 1;
  String realMessage = message.substring(startIdx, endIdx);
  processErrno(realMessage, e);
}
origin: kframework/k

  void close() throws IOException {
    try {
      os.close();
    } catch (IOException e) {
      PortableFileSystem.processIOException(e);
    }
  }
}
origin: kframework/k

  void close() throws IOException {
    try {
      is.close();
    } catch (IOException e) {
      PortableFileSystem.processIOException(e);
    }
  }
}
origin: kframework/k

public void seek(long pos) throws IOException {
  try {
    raf.seek(pos);
  } catch (IOException e) {
    PortableFileSystem.processIOException(e);
  }
}
origin: kframework/k

  void close() throws IOException {
    try {
      raf.close();
    } catch (IOException e) {
      PortableFileSystem.processIOException(e);
    }
  }
}
origin: kframework/k

public void putc(byte b) throws IOException {
  try {
    os.write(b);
  } catch (IOException e) {
    PortableFileSystem.processIOException(e);
  } finally {
    os.flush();
  }
}
origin: kframework/k

public byte getc() throws IOException {
  int read;
  try {
    read = is.read();
  } catch (IOException e) {
    PortableFileSystem.processIOException(e);
    throw e; //unreachable
  }
  if (read == -1) {
    throw new IOException("EOF");
  }
  return (byte)read;
}
origin: kframework/k

public void write(byte[] b) throws IOException {
  try {
    os.write(b);
  } catch (IOException e) {
    PortableFileSystem.processIOException(e);
  } finally {
    os.flush();
  }
}
origin: kframework/k

public byte[] read(int n) throws IOException {
  int read;
  byte[] bytes;
  try {
    bytes = new byte[n];
    read = is.read(bytes);
  } catch (IOException e) {
    PortableFileSystem.processIOException(e);
    throw e; //unreachable
  }
  if (read == -1) {
    throw new IOException("EOF");
  }
  return Arrays.copyOfRange(bytes, 0, read);
}
origin: kframework/k

public byte[] read(int n) throws IOException {
  int read;
  byte[] bytes;
  try {
    bytes = new byte[n];
    read = raf.read(bytes);
  } catch (IOException e) {
    PortableFileSystem.processIOException(e);
    throw e; //unreachable
  }
  if (read == -1) {
    throw new IOException("EOF");
  }
  return Arrays.copyOfRange(bytes, 0, read);
}
origin: kframework/k

public byte getc() throws IOException {
  try {
    return raf.readByte();
  } catch (IOException e) {
    PortableFileSystem.processIOException(e);
    throw e; //unreachable
  }
}
origin: kframework/k

public void putc(byte b) throws IOException {
  try {
    raf.writeByte(b);
  } catch (IOException e) {
    PortableFileSystem.processIOException(e);
  }
}
org.kframework.krun.ioserver.filesystem.portablePortableFileSystem

Most used methods

  • get
  • <init>
  • open
  • processErrno
  • processFileNotFoundException
  • processIOException

Popular in Java

  • Making http post requests using okhttp
  • getExternalFilesDir (Context)
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • scheduleAtFixedRate (ScheduledExecutorService)
  • Color (java.awt)
    The Color class is used to encapsulate colors in the default sRGB color space or colors in arbitrary
  • Kernel (java.awt.image)
  • InputStreamReader (java.io)
    A class for turning a byte stream into a character stream. Data read from the source input stream is
  • Date (java.util)
    A specific moment in time, with millisecond precision. Values typically come from System#currentTime
  • Enumeration (java.util)
    A legacy iteration interface.New code should use Iterator instead. Iterator replaces the enumeration
  • JCheckBox (javax.swing)
  • Top Sublime Text plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now