예제 #1
0
 @Override
 public long seek(long offset, SeekMode seekMode, SeekRWMode seekRWMode) throws IOException {
   long result = raf.getFilePointer();
   switch (seekMode) {
     case ENQUIRE:
       return result;
     case START:
       break;
     default:
       throw RError.nyi(RError.SHOW_CALLER, "seek mode");
   }
   switch (seekRWMode) {
     case LAST:
       if (lastMode == SeekRWMode.READ) {
         readOffset = offset;
       } else {
         writeOffset = offset;
       }
       break;
     case READ:
       readOffset = offset;
       break;
     case WRITE:
       writeOffset = offset;
       break;
   }
   return result;
 }
예제 #2
0
 @Override
 protected void createDelegateConnection() throws IOException {
   DelegateRConnection delegate = null;
   switch (getOpenMode().abstractOpenMode) {
     case Read:
       delegate = new FileReadTextRConnection(this);
       break;
     case Write:
       delegate = new FileWriteTextRConnection(this, false);
       break;
     case Append:
       delegate = new FileWriteTextRConnection(this, true);
       break;
     case ReadBinary:
       delegate = new FileReadBinaryRConnection(this);
       break;
     case WriteBinary:
       delegate = new FileWriteBinaryConnection(this, false);
       break;
     case ReadWriteTrunc:
     case ReadWriteTruncBinary:
       delegate = new FileReadWriteConnection(this);
       break;
     default:
       throw RError.nyi(RError.SHOW_CALLER2, "open mode: " + getOpenMode());
   }
   setDelegate(delegate);
 }
예제 #3
0
 FileReadTextRConnection(BasePathRConnection base) throws IOException {
   super(base);
   // can be compressed - check for it
   RCompression.Type cType = RCompression.getCompressionType(base.path);
   switch (cType) {
     case NONE:
       inputStream = new BufferedInputStream(new FileInputStream(base.path));
       break;
     case GZIP:
       inputStream =
           new GZIPInputStream(new FileInputStream(base.path), GZIPConnections.GZIP_BUFFER_SIZE);
       break;
     default:
       throw RError.nyi(RError.SHOW_CALLER2, "compression type: " + cType.name());
   }
 }
예제 #4
0
 protected RuntimeException fallback(Object fobj) {
   String name = null;
   if (fobj instanceof RList) {
     name = lookupName((RList) fobj);
     name = name == UNKNOWN_EXTERNAL_BUILTIN ? null : name;
     if (name != null && lookupBuiltin((RList) fobj) != null) {
       /*
        * if we reach this point, then the cache saw a different value for f. the lists
        * that contain the information about native calls are never expected to change.
        */
       throw RInternalError.shouldNotReachHere(
           "fallback reached for " + getRBuiltin().name() + " " + name);
     }
   }
   throw RError.nyi(
       this,
       getRBuiltin().name() + " specialization failure: " + (name == null ? "<unknown>" : name));
 }