Package freenet.support.io

Examples of freenet.support.io.FileBucket


        throw new MessageInvalidException(ProtocolErrorMessage.MISSING_FIELD, "Missing field Filename", identifier, global);
      File f = new File(filename);
      if(!(f.exists() && f.isFile() && f.canRead()))
        throw new MessageInvalidException(ProtocolErrorMessage.FILE_NOT_FOUND, null, identifier, global);
      dataLength = f.length();
      FileBucket fileBucket = new FileBucket(f, true, false, false, false);
      this.bucket = fileBucket;
      this.origFilename = f;
      redirectTarget = null;
      if(fnam == null)
        fnam = origFilename.getName();
View Full Code Here


                System.err.println("Cannot deploy multi-file update for "+name+" without /dev/null");
                return null;
            }
            File restartFreenet = new File(RESTART_SCRIPT_NAME);
            restartFreenet.delete();
            FileBucket fb = new FileBucket(restartFreenet, false, true, false, false);
            OutputStream os = null;
            try {
                os = new BufferedOutputStream(fb.getOutputStream());
                OutputStreamWriter osw = new OutputStreamWriter(os, "ISO-8859-1"); // Right???
                osw.write("#!/bin/sh\n"); // FIXME exec >/dev/null 2>&1 ???? Believed to be portable.
                //osw.write("trap true PIPE\n"); - should not be necessary
                osw.write("while kill -0 "+WrapperManager.getWrapperPID()+" > /dev/null 2>&1; do sleep 1; done\n");
                osw.write("./"+runshNoNice+" start > /dev/null 2>&1\n");
View Full Code Here

     
        if(f.isHidden() && !includeHiddenFiles) continue;

      if (f.exists() && f.canRead()) {
        if(f.isFile()) {
          FileBucket bucket = new FileBucket(f, true, false, false, false);
          if(logMINOR)
            Logger.minor(this, "Add file : " + f.getAbsolutePath());
         
          map.put(f.getName(), new ManifestElement(f.getName(), prefix + f.getName(), bucket, DefaultMIMETypes.guessMIMEType(f.getName(), true), f.length()));
        } else if(f.isDirectory()) {
View Full Code Here

            File.createTempFile(blobFilenamePrefix + availableVersion + "-", ".fblob.tmp", manager.node.clientCore.getPersistentTempDir());
          FreenetURI uri = URI.setSuggestedEdition(availableVersion);
          uri = uri.sskForUSK();
          cg = new ClientGetter(this, 
            uri, ctx, RequestStarter.IMMEDIATE_SPLITFILE_PRIORITY_CLASS,
            null, new BinaryBlobWriter(new FileBucket(tempBlobFile, false, false, false, false)), null);
          toStart = cg;
        } else {
          System.err.println("Already fetching "+jarName() + " fetch for " + fetchingVersion + " want "+availableVersion);
        }
        isFetching = true;
View Full Code Here

  }
 
  RandomAccessBucket getBlobBucket(int availableVersion) {
    File f = getBlobFile(availableVersion);
    if(f == null) return null;
    return new FileBucket(f, true, false, false, false);
  }
View Full Code Here

                    Logger.error(this, "Target file already exists but is zero length, deleting...");
          }
          if(targetFile.exists())
              throw new IOException("Target filename exists already: "+targetFile);
      }
      ret = new FileBucket(returnFilename, false, true, false, false);
      if(filterData) {
        String name = returnFilename.getName();
        int idx = name.lastIndexOf('.');
        if(idx != -1) {
          idx++;
View Full Code Here

      this.targetFile = message.diskFile;
      if(!core.allowDownloadTo(targetFile))
        throw new MessageInvalidException(ProtocolErrorMessage.ACCESS_DENIED, "Not allowed to download to "+targetFile, identifier, global);
      else if(!(handler.allowDDAFrom(targetFile, true)))
        throw new MessageInvalidException(ProtocolErrorMessage.DIRECT_DISK_ACCESS_DENIED, "Not allowed to download to " + targetFile + ". You might need to do a " + TestDDARequestMessage.NAME + " first.", identifier, global);
      ret = new FileBucket(targetFile, false, true, false, false);
      if(fctx.filterData) {
        String name = targetFile.getName();
        int idx = name.lastIndexOf('.');
        if(idx != -1) {
          idx++;
View Full Code Here

      if(returnType == ReturnType.DIRECT) {
          synchronized(this) {
              return returnBucketDirect;
          }
      } else if(returnType == ReturnType.DISK) {
          return new FileBucket(targetFile, readOnly, false, false, false);
      } else {
          return null;
      }
  }
View Full Code Here

        if (mimeType == null) {
          throw new MessageInvalidException(ProtocolErrorMessage.BAD_MIME_TYPE, "Could not determine MIME type from filename", identifier, false);
        }
      }
      dataLength = -1;
      this.bucket = new FileBucket(file, true, false, false, false);
    } else {
      throw new MessageInvalidException(ProtocolErrorMessage.INVALID_FIELD, "Illegal DataSource value", identifier, false);
    }
    this.bf = bf;
  }
View Full Code Here

    //   Skip files nonexistant (dangling symlinks) - check last
          if (filelist[i].canRead() && filelist[i].exists()) {
            if (filelist[i].isFile()) {
              File f = filelist[i];
             
              FileBucket bucket = new FileBucket(f, true, false, false, false);
             
              ret.put(f.getName(), new ManifestElement(f.getName(), prefix + f.getName(), bucket, DefaultMIMETypes.guessMIMEType(f.getName(), true), f.length()));
            } else if(filelist[i].isDirectory()) {
              HashMap<String, Object> subdir = makeBucketsByName(new File(thisdir, filelist[i].getName()), prefix
                  + filelist[i].getName() + '/');
View Full Code Here

TOP

Related Classes of freenet.support.io.FileBucket

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.