All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.jsync.file.impl.WindowsFileSystem Maven / Gradle / Ivy

There is a newer version: 1.10.13
Show newest version
/*
 * Copyright (c) 2011-2013 The original author or authors
 * ------------------------------------------------------
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * and Apache License v2.0 which accompanies this distribution.
 *
 *     The Eclipse Public License is available at
 *     http://www.eclipse.org/legal/epl-v10.html
 *
 *     The Apache License v2.0 is available at
 *     http://www.opensource.org/licenses/apache2.0.php
 *
 * You may elect to redistribute this code under either of these licenses.
 */

package io.jsync.file.impl;

import io.jsync.AsyncResult;
import io.jsync.Handler;
import io.jsync.file.AsyncFile;
import io.jsync.impl.AsyncInternal;
import io.jsync.impl.BlockingAction;
import io.jsync.impl.DefaultContext;
import io.jsync.logging.Logger;
import io.jsync.logging.impl.LoggerFactory;

/**
 * @author Tim Fox
 * @author Juergen Donnerstag
 */
public class WindowsFileSystem extends DefaultFileSystem {

    private static final Logger log = LoggerFactory.getLogger(WindowsFileSystem.class);

    public WindowsFileSystem(final AsyncInternal async) {
        super(async);
    }

    private static void logInternal(final String perms) {
        if (perms != null && log.isDebugEnabled()) {
            log.debug("You are running on Windows and POSIX style file permissions are not supported");
        }
    }

    @Override
    protected BlockingAction chmodInternal(String path, String perms, String dirPerms,
                                                 Handler> handler) {
        logInternal(perms);
        logInternal(dirPerms);
        return new BlockingAction(async, handler) {
            @Override
            public Void action() {
                return null;
            }
        };
    }

    @Override
    protected BlockingAction mkdirInternal(String path, final String perms, final boolean createParents,
                                                 Handler> handler) {
        logInternal(perms);
        return super.mkdirInternal(path, null, createParents, handler);
    }

    @Override
    protected AsyncFile doOpen(String path, String perms, boolean read, boolean write, boolean createNew, boolean flush,
                               DefaultContext context) {
        logInternal(perms);
        return new DefaultAsyncFile(async, path, null, read, write, createNew, flush, context);
    }

    @Override
    protected BlockingAction createFileInternal(String p, final String perms, Handler> handler) {
        logInternal(perms);
        return super.createFileInternal(p, null, handler);
    }

    @Override
    protected BlockingAction chownInternal(String path, String user, String group, Handler> handler) {
        if (group != null && log.isDebugEnabled()) {
            log.debug("You are running on Windows and POSIX style file ownership is not supported");
        }
        return super.chownInternal(path, user, group, handler);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy