Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Issue #745 #753

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions src/main/java/com/hierynomus/smbj/utils/SmbFileUtil.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*
* Copyright (C)2023 - SMBJ Contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.hierynomus.smbj.utils;

import com.hierynomus.mssmb2.SMBApiException;
import com.hierynomus.smbj.common.SmbPath;
import com.hierynomus.smbj.share.DiskShare;

/**
* Utility class for working with files and paths
*/
public class SmbFileUtil {

private static final SmbFiles SMB_FILES = new SmbFiles();

private SmbFileUtil() {
// private as this utility class should not be instantiated
}

/**
* Creates a set of nested subdirectories in the given path, for example, 2345\3456\4453\123123.txt
*
* @param diskShare the share
* @param path the path to create
* @throws SMBApiException when an SMB error occurs
*/
public void mkdirs(DiskShare diskShare, String path) throws SMBApiException {
SMB_FILES.mkdirs(diskShare, path);
}

/**
* Creates a set of nested subdirectories in the given path, for example, 2345\3456\4453\123123.txt
*
* @param diskShare the share
* @param path the path to create
* @throws SMBApiException when an SMB error occurs
*/
public void mkdirs(DiskShare diskShare, SmbPath path) throws SMBApiException {
SMB_FILES.mkdirs(diskShare, path);
}

}
4 changes: 4 additions & 0 deletions src/main/java/com/hierynomus/smbj/utils/SmbFiles.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,19 @@ public static long copy(File source, DiskShare share, String destPath, boolean o

/**
* Create a set of nested sub-directories in the given path, for example, 2345 \ 3456 \ 4453 \ 123123.txt
* @deprecated use static {@link SmbFileUtil#mkdirs(DiskShare, String)} method instead
*/
@Deprecated
public void mkdirs(DiskShare diskShare, String path) throws SMBApiException {
SmbPath smbPath = new SmbPath(diskShare.getSmbPath(), path);
mkdirs(diskShare, smbPath);
}

/**
* Create a set of nested sub-directories in the given path, for example, 2345 \ 3456 \ 4453 \ 123123.txt
* @deprecated use static {@link SmbFileUtil#mkdirs(DiskShare, SmbPath)} method instead
*/
@Deprecated
public void mkdirs(DiskShare diskShare, SmbPath path) throws SMBApiException {
if (!diskShare.folderExists(path.getPath())) {
// Ensure the parent path exists
Expand Down