当前位置: 首页>>代码示例>>Java>>正文


Java FileDescriptor.valid方法代码示例

本文整理汇总了Java中java.io.FileDescriptor.valid方法的典型用法代码示例。如果您正苦于以下问题:Java FileDescriptor.valid方法的具体用法?Java FileDescriptor.valid怎么用?Java FileDescriptor.valid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.io.FileDescriptor的用法示例。


在下文中一共展示了FileDescriptor.valid方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setOption

import java.io.FileDescriptor; //导入方法依赖的package包/类
@Override
public void setOption(FileDescriptor fd,
                      SocketOption<?> option,
                      Object value)
    throws SocketException
{
    SecurityManager sm = System.getSecurityManager();
    if (sm != null)
        sm.checkPermission(new NetworkPermission("setOption." + option.name()));

    if (fd == null || !fd.valid())
        throw new SocketException("socket closed");

    if (option == SO_FLOW_SLA) {
        assert flowSupported;
        SocketFlow flow = checkValueType(value, option.type());
        setFlowOption(fd, flow);
    } else {
        throw new InternalError("Unexpected option " + option);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:22,代码来源:ExtendedSocketOptions.java

示例2: getOption

import java.io.FileDescriptor; //导入方法依赖的package包/类
@Override
public Object getOption(FileDescriptor fd,
                        SocketOption<?> option)
    throws SocketException
{
    SecurityManager sm = System.getSecurityManager();
    if (sm != null)
        sm.checkPermission(new NetworkPermission("getOption." + option.name()));

    if (fd == null || !fd.valid())
        throw new SocketException("socket closed");

    if (option == SO_FLOW_SLA) {
        assert flowSupported;
        SocketFlow flow = SocketFlow.create();
        getFlowOption(fd, flow);
        return flow;
    } else {
        throw new InternalError("Unexpected option " + option);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:22,代码来源:ExtendedSocketOptions.java

示例3: closeQuietly

import java.io.FileDescriptor; //导入方法依赖的package包/类
public static void closeQuietly(FileDescriptor fd) {

        if (fd != null && fd.valid()) {
            try {
                Os.close(fd);
            } catch (ErrnoException e) {
                e.printStackTrace();
            }
        }
    }
 
开发者ID:7763sea,项目名称:VirtualHook,代码行数:11,代码来源:FileBridge.java

示例4: getFileDescriptor

import java.io.FileDescriptor; //导入方法依赖的package包/类
public static FileDescriptor getFileDescriptor(Context context, String filename) {
    MemoryFile mf = sCache.get(filename);

    if (mf != null) {
        Log.i(TAG, "MemoryFile " + filename + " is in the cache");

        FileDescriptor fd = MemoryFileUtils.getFileDescriptor(mf);
        if (fd != null && fd.valid()) {
            return fd;
        } else {
            Log.i(TAG, "MemoryFile " + filename + " is not valid?");
        }
    }

    long time = System.currentTimeMillis();

    Log.i(TAG, "loading file " + filename);

    // built in font? read from asset
    if (BUILT_IN_FONTS_SIZE.containsKey(filename)) {
        mf = MemoryFileUtils.fromAsset(context.getAssets(), filename, FILE_SIZE.get(filename));
    }

    // downloadable font? read from file
    if (mf == null) {
        File file = ContextUtils.getExternalFile(context, filename);
        if (file.exists()) {
            mf = MemoryFileUtils.fromFile(file);
            if (mf != null) {
                FILE_SIZE.put(filename, mf.length());
            }
        }
    }

    // file not exist?
    if (mf == null) {
        Log.w(TAG, "loading " + filename + " failed");
        return null;
    }

    Log.i(TAG, "loading finished in " + (System.currentTimeMillis() - time) + "ms");
    sCache.put(filename, mf);

    return MemoryFileUtils.getFileDescriptor(mf);
}
 
开发者ID:RikkaApps,项目名称:FontProvider,代码行数:46,代码来源:FontManager.java

示例5: setDataSource

import java.io.FileDescriptor; //导入方法依赖的package包/类
public void setDataSource(Context context, Uri uri)
    throws IllegalArgumentException, SecurityException {
    if (uri == null) {
        throw new IllegalArgumentException();
    }
    
    String scheme = uri.getScheme();
    if (SmbProxy.needToStream(scheme)){
        mSmbProxy = SmbProxy.setDataSource(uri, this, null);
        return;
    }
    if(scheme == null || scheme.equals("file")) {
        setDataSource(uri.getPath());
        return;
    }

    AssetFileDescriptor fd = null;
    try {
        ContentResolver resolver = context.getContentResolver();
        try {
            fd = resolver.openAssetFileDescriptor(uri, "r");
        } catch(FileNotFoundException e) {
            throw new IllegalArgumentException();
        }
        if (fd == null) {
            throw new IllegalArgumentException();
        }
        FileDescriptor descriptor = fd.getFileDescriptor();
        if (!descriptor.valid()) {
            throw new IllegalArgumentException();
        }
        // Note: using getDeclaredLength so that our behavior is the same
        // as previous versions when the content provider is returning
        // a full file.
        if (fd.getDeclaredLength() < 0) {
            setDataSource(descriptor);
        } else {
            setDataSource(descriptor, fd.getStartOffset(), fd.getDeclaredLength());
        }
        return;
    } catch (SecurityException ex) {
    } finally {
        try {
            if (fd != null) {
                fd.close();
            }
        } catch(IOException ioEx) {
        }
    }
    setDataSource(uri.toString(), null, null);
}
 
开发者ID:archos-sa,项目名称:aos-MediaLib,代码行数:52,代码来源:AvosMediaMetadataRetriever.java


注:本文中的java.io.FileDescriptor.valid方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。