亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? localfilesystem.java

?? 爬蟲數據的改進,并修正了一些bug
?? JAVA
字號:
/* Copyright (c) 2004 The Nutch Organization.  All rights reserved.   */
/* Use subject to the conditions in http://www.nutch.org/LICENSE.txt. */

package net.nutch.fs;

import java.io.*;
import java.util.*;
import java.nio.channels.*;

import net.nutch.ndfs.NDFSFile;
import net.nutch.ndfs.NDFSFileInfo;
import net.nutch.io.UTF8;

/****************************************************************
 * Implement the NutchFileSystem interface for the local disk.
 * This is pretty easy.  The interface exists so we can use either
 * remote or local Files very easily.
 *
 * @author Mike Cafarella
 *****************************************************************/
public class LocalFileSystem extends NutchFileSystem {
    TreeMap sharedLockDataSet = new TreeMap();
    TreeMap nonsharedLockDataSet = new TreeMap();
    TreeMap lockObjSet = new TreeMap();
    // by default use copy/delete instead of rename
    boolean useCopyForRename = true;

    /**
     */
    public LocalFileSystem() throws IOException {
        super();
        // if you find an OS which reliably supports non-POSIX
        // rename(2) across filesystems / volumes, you can
        // uncomment this.
        // String os = System.getProperty("os.name");
        // if (os.toLowerCase().indexOf("os-with-super-rename") != -1)
        //     useCopyForRename = false;
    }

    /*******************************************************
     * For open()'s NFSInputStream
     *******************************************************/
    class LocalNFSFileInputStream extends NFSInputStream {
        FileInputStream fis;

        public LocalNFSFileInputStream(File f) throws IOException {
          this.fis = new FileInputStream(f);
        }

        public void seek(long pos) throws IOException {
          fis.getChannel().position(pos);
        }

        public long getPos() throws IOException {
          return fis.getChannel().position();
        }

        /*
         * Just forward to the fis
         */
        public int available() throws IOException { return fis.available(); }
        public void close() throws IOException { fis.close(); }
        public boolean markSupport() { return false; }
        public int read() throws IOException { return fis.read(); }
        public int read(byte[] b) throws IOException { return fis.read(b); }
        public int read(byte[] b, int off, int len) throws IOException {
            return fis.read(b, off, len);
        }
        public long skip(long n) throws IOException { return fis.skip(n); }
    }
    
    /**
     * Open the file at f
     */
    public NFSInputStream open(File f) throws IOException {
        if (! f.exists()) {
            throw new IOException("File does not exist");
        }
        return new LocalNFSFileInputStream(f);
    }

    /**
     * Create the file at f.
     */
    public NFSOutputStream create(File f) throws IOException {
        return create(f, false);
    }

    /*********************************************************
     * For create()'s NFSOutputStream.
     *********************************************************/
    class LocalNFSFileOutputStream extends NFSOutputStream {
      FileOutputStream fos;

      public LocalNFSFileOutputStream(File f) throws IOException {
        this.fos = new FileOutputStream(f);
      }

      public long getPos() throws IOException {
        return fos.getChannel().position();
      }

      /*
       * Just forward to the fos
       */
      public void close() throws IOException { fos.close(); }
      public void flush() throws IOException { fos.flush(); }
      public void write(byte[] b) throws IOException { fos.write(b); }
      public void write(byte[] b, int off, int len) throws IOException {
        fos.write(b, off, len);
      }
      public void write(int b) throws IOException { fos.write(b); }
    }

    /**
     */
    public NFSOutputStream create(File f, boolean overwrite) throws IOException {
        if (f.exists() && ! overwrite) {
            throw new IOException("File already exists");
        }
        File parent = f.getParentFile();
        if (parent != null)
          parent.mkdirs();

        return new LocalNFSFileOutputStream(f);
    }

    /**
     * Rename files/dirs
     */
    public boolean rename(File src, File dst) throws IOException {
        if (useCopyForRename) {
            FileUtil.copyContents(this, src, dst, true);
            return fullyDelete(src);
        } else return src.renameTo(dst);
    }

    /**
     * Get rid of File f, whether a true file or dir.
     */
    public boolean delete(File f) throws IOException {
        if (f.isFile()) {
            return f.delete();
        } else return fullyDelete(f);
    }

    /**
     */
    public boolean exists(File f) throws IOException {
        return f.exists();
    }

    /**
     */
    public boolean isDirectory(File f) throws IOException {
        return f.isDirectory();
    }

    /**
     */
    public long getLength(File f) throws IOException {
        return f.length();
    }

    /**
     */
    public File[] listFiles(File f) throws IOException {
        File[] files = f.listFiles();
        if (files == null) return null;
        // 20041022, xing, Watch out here:
        // currently NDFSFile.java does not support those methods
        //    public boolean canRead()
        //    public boolean canWrite()
        //    public boolean createNewFile()
        //    public boolean delete()
        //    public void deleteOnExit()
        //    public boolean isHidden()
        // so you can not rely on returned list for these operations.
        NDFSFile[] nfiles = new NDFSFile[files.length];
        for (int i = 0; i < files.length; i++) {
            long len = files[i].length();
            UTF8 name = new UTF8(files[i].toString());
            NDFSFileInfo info = new NDFSFileInfo(name, len, len, files[i].isDirectory());
            nfiles[i] = new NDFSFile(info);
        }
        return nfiles;
    }

    /**
     */
    public void mkdirs(File f) throws IOException {
        f.mkdirs();
    }

    /**
     * Obtain a filesystem lock at File f.
     */
    public synchronized void lock(File f, boolean shared) throws IOException {
        f.createNewFile();

        FileLock lockObj = null;
        if (shared) {
            FileInputStream lockData = new FileInputStream(f);
            lockObj = lockData.getChannel().lock(0L, Long.MAX_VALUE, shared);
            sharedLockDataSet.put(f, lockData);
        } else {
            FileOutputStream lockData = new FileOutputStream(f);
            lockObj = lockData.getChannel().lock(0L, Long.MAX_VALUE, shared);
            nonsharedLockDataSet.put(f, lockData);
        }
        lockObjSet.put(f, lockObj);
    }

    /**
     * Release a held lock
     */
    public synchronized void release(File f) throws IOException {
        FileLock lockObj = (FileLock) lockObjSet.get(f);
        FileInputStream sharedLockData = (FileInputStream) sharedLockDataSet.get(f);
        FileOutputStream nonsharedLockData = (FileOutputStream) nonsharedLockDataSet.get(f);

        if (lockObj == null) {
            throw new IOException("Given target not held as lock");
        }
        if (sharedLockData == null && nonsharedLockData == null) {
            throw new IOException("Given target not held as lock");
        }

        lockObj.release();
        lockObjSet.remove(f);
        if (sharedLockData != null) {
            sharedLockData.close();
            sharedLockDataSet.remove(f);
        } else {
            nonsharedLockData.close();
            nonsharedLockDataSet.remove(f);
        }
    }

    /**
     * In the case of the local filesystem, we can just rename the file.
     */
    public void moveFromLocalFile(File src, File dst) throws IOException {
        if (! src.equals(dst)) {
            if (useCopyForRename) {
                FileUtil.copyContents(this, src, dst, true);
                fullyDelete(src);
            } else src.renameTo(dst);
        }
    }

    /**
     * Similar to moveFromLocalFile(), except the source is kept intact.
     */
    public void copyFromLocalFile(File src, File dst) throws IOException {
        if (! src.equals(dst)) {
            FileUtil.copyContents(this, src, dst, true);
        }
    }

    /**
     * We can't delete the src file in this case.  Too bad.
     */
    public void copyToLocalFile(File src, File dst) throws IOException {
        if (! src.equals(dst)) {
            FileUtil.copyContents(this, src, dst, true);
        }
    }

    /**
     * We can write output directly to the final location
     */
    public File startLocalOutput(File nfsOutputFile, File tmpLocalFile) throws IOException {
        return nfsOutputFile;
    }

    /**
     * It's in the right place - nothing to do.
     */
    public void completeLocalOutput(File nfsWorkingFile, File tmpLocalFile) throws IOException {
    }

    /**
     * We can read directly from the real local fs.
     */
    public File startLocalInput(File nfsInputFile, File tmpLocalFile) throws IOException {
        return nfsInputFile;
    }

    /**
     * We're done reading.  Nothing to clean up.
     */
    public void completeLocalInput(File localFile) throws IOException {
        // Ignore the file, it's at the right destination!
    }

    /**
     * Create a temp file by just calling the Java method
     */
    public File createTempFile(String prefix, String suffix, File directory) throws IOException {
        return new File(prefix + "-" + System.currentTimeMillis() + "-" + suffix);
    }

    /**
     * Shut down the FS.  Not necessary for regular filesystem.
     */
    public void close() throws IOException {
    }

    /**
     */
    public String toString() {
        return "LocalFS";
    }
    
    /**
     * Implement our own version instead of using the one in FileUtil,
     * to avoid infinite recursion.
     * @param dir
     * @return
     * @throws IOException
     */
    private boolean fullyDelete(File dir) throws IOException {
        File contents[] = dir.listFiles();
        if (contents != null) {
            for (int i = 0; i < contents.length; i++) {
                if (contents[i].isFile()) {
                    if (! contents[i].delete()) {
                        return false;
                    }
                } else {
                    if (! fullyDelete(contents[i])) {
                        return false;
                    }
                }
            }
        }
        return dir.delete();
    }
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲国产精品一区二区久久恐怖片 | 极品美女销魂一区二区三区免费| 男女激情视频一区| 成人18精品视频| 91麻豆精品国产91久久久久 | 99久久精品免费| 欧美高清精品3d| 国产精品久久久久影院亚瑟| 亚洲国产欧美一区二区三区丁香婷| 国产在线播放一区三区四| 欧日韩精品视频| 中文字幕中文在线不卡住| 日韩黄色免费网站| 色综合久久久网| 欧美国产在线观看| 国产美女在线观看一区| 在线观看91视频| 国产精品入口麻豆九色| 开心九九激情九九欧美日韩精美视频电影 | 精品在线一区二区三区| 欧美在线综合视频| 亚洲天堂久久久久久久| 粉嫩av亚洲一区二区图片| 日韩欧美国产麻豆| 日韩精品1区2区3区| 欧美网站大全在线观看| 亚洲另类在线制服丝袜| 99久久精品情趣| 亚洲女性喷水在线观看一区| 风间由美一区二区三区在线观看| 欧美r级电影在线观看| 三级欧美韩日大片在线看| 在线观看日韩精品| 一片黄亚洲嫩模| 色婷婷香蕉在线一区二区| 国产精品欧美经典| 韩国av一区二区| 欧美不卡一区二区三区四区| 亚洲综合一区在线| 99综合影院在线| 国产精品乱人伦| 高清国产午夜精品久久久久久| 欧美精选在线播放| 亚洲成人福利片| 欧美午夜精品一区二区蜜桃| 国产精品全国免费观看高清| 韩国精品一区二区| 欧美成va人片在线观看| 蜜臂av日日欢夜夜爽一区| 欧美在线999| 亚洲国产精品传媒在线观看| 美脚の诱脚舐め脚责91| 91精品国产91久久久久久最新毛片| 一区二区三区91| 91久久精品国产91性色tv| 亚洲人成影院在线观看| 日韩不卡一区二区三区| 欧美视频在线不卡| 日韩中文字幕区一区有砖一区| 日本韩国欧美一区| 亚洲444eee在线观看| 91麻豆精品久久久久蜜臀| 午夜精品久久久久久久久| 在线观看日韩毛片| 午夜激情久久久| 日韩一区二区免费在线观看| 美女被吸乳得到大胸91| 久久久久久久久久久久久夜| 国产91丝袜在线18| **性色生活片久久毛片| 91国偷自产一区二区使用方法| 一区二区三区中文字幕精品精品| 欧美日韩一本到| 青青青爽久久午夜综合久久午夜| 成人激情开心网| 国产精品久久久久久久久快鸭 | 国产精品自拍毛片| 国产喷白浆一区二区三区| 成人在线综合网| 亚洲伦在线观看| 91精品国产aⅴ一区二区| 久久超碰97中文字幕| 国产精品色噜噜| 欧美在线影院一区二区| 久久成人麻豆午夜电影| 中文字幕一区二区三区色视频| 91官网在线免费观看| 日韩国产欧美在线播放| 久久久久久久久久电影| 91视频.com| 免费亚洲电影在线| 国产精品久久久久7777按摩 | 日本免费新一区视频| 国产日韩亚洲欧美综合| 日本大香伊一区二区三区| 看片的网站亚洲| 一区二区三区丝袜| 日韩欧美亚洲另类制服综合在线| 在线观看视频一区二区欧美日韩| 麻豆精品一二三| 亚洲精品国产视频| 亚洲精品在线观看视频| 欧美在线观看视频一区二区三区| 国产一区二区三区美女| 亚洲成在人线免费| 久久精品免视看| 日韩欧美亚洲国产另类| 91精品福利视频| 国产一区二区福利视频| 日韩—二三区免费观看av| 中文字幕一区二区三区精华液 | 亚洲国产欧美日韩另类综合| 国产亚洲一区二区三区| 欧美精品久久天天躁| 成人免费高清视频| 麻豆国产精品视频| 日韩激情一区二区| 亚洲一区二区不卡免费| 亚洲日本丝袜连裤袜办公室| 日本一区二区三区久久久久久久久不 | 欧美成人激情免费网| 色综合天天天天做夜夜夜夜做| 国产夫妻精品视频| 国产一区二区三区免费观看| 奇米影视在线99精品| 亚洲一二三四在线观看| 亚洲欧美精品午睡沙发| 国产精品久久久久久久午夜片 | 99视频热这里只有精品免费| 狠狠色综合色综合网络| 久久精品国产999大香线蕉| 亚洲国产婷婷综合在线精品| 亚洲色图色小说| 亚洲欧美激情小说另类| 亚洲男人电影天堂| 中文在线一区二区| 综合色天天鬼久久鬼色| 亚洲欧美韩国综合色| 一区二区三区不卡在线观看 | 欧美成人女星排行榜| 日韩一二三区不卡| 日韩一卡二卡三卡四卡| 91精品国产综合久久精品图片| 欧美日韩国产123区| 欧美日韩精品免费观看视频| 欧美精品在线一区二区| 91精品国产综合久久香蕉麻豆 | 国产精品色哟哟| 69精品人人人人| 欧美大黄免费观看| 精品国产欧美一区二区| 国产丝袜在线精品| 中文字幕一区二区三区蜜月| 亚洲精品国产第一综合99久久| 亚洲午夜激情av| 蜜臀91精品一区二区三区| 精品一区二区三区视频在线观看| 国产成人精品1024| 色综合久久综合网97色综合| 欧美日韩一二三| 欧美日韩极品在线观看一区| 91麻豆精品91久久久久久清纯| 欧美日韩高清影院| 国产午夜一区二区三区| 中文字幕在线不卡视频| 亚洲综合色区另类av| 狠狠色2019综合网| 99久久久国产精品| 欧美日韩国产在线播放网站| 精品国产成人在线影院| 精品成人免费观看| 亚洲特黄一级片| 视频在线在亚洲| 成人久久视频在线观看| 欧美日韩视频在线观看一区二区三区 | 久久久欧美精品sm网站| 亚洲麻豆国产自偷在线| 青青草原综合久久大伊人精品优势| 国产精品中文欧美| 91蜜桃免费观看视频| 欧美一区二区三区在线看| 亚洲欧美视频一区| 狠狠久久亚洲欧美| 欧美丝袜自拍制服另类| 久久久久久久久一| 亚洲一区在线视频观看| 国产成人精品影视| 欧美夫妻性生活| 亚洲靠逼com| 国产精品538一区二区在线| 欧美日韩亚州综合| 亚洲免费色视频| 国产精品一区二区黑丝| 精品视频在线看| 18成人在线视频| 成人一区二区在线观看| 精品卡一卡二卡三卡四在线| 亚洲一二三四区| 95精品视频在线| 国产精品区一区二区三|