diff options
Diffstat (limited to 'libs/samba/src/main/cpp/samba.cpp')
| -rw-r--r-- | libs/samba/src/main/cpp/samba.cpp | 35 |
1 files changed, 0 insertions, 35 deletions
diff --git a/libs/samba/src/main/cpp/samba.cpp b/libs/samba/src/main/cpp/samba.cpp index ed73d62..38ad5da 100644 --- a/libs/samba/src/main/cpp/samba.cpp +++ b/libs/samba/src/main/cpp/samba.cpp @@ -192,30 +192,6 @@ class Context { return smb2_unlink(context_.get(), path.c_str()) == 0; } - std::optional<std::string> ReadLink(const std::string& path) { - // Good to start with a fairly small size as current implementation - // of smb2_readlink uses strncpy, which pads the whole unused buffer - // with zeros. - uint32_t bufsize = 256; - std::vector<char> buf; - while (true) { - buf.resize(bufsize); - auto ret = smb2_readlink(context_.get(), path.c_str(), buf.data(), bufsize); - if (ret != 0) - return std::nullopt; - // smb2_readlink uses strncpy, so if actual path was larger than bufsize - // there will be no terminating zero. - auto it = std::find(buf.begin(), buf.end(), '\0'); - if (it != buf.end()) - return std::string(buf.begin(), it); - const auto previous = bufsize; - bufsize *= 2; - // Check for bufsize (a uint32_t) overflow. - if (bufsize <= previous) - return std::nullopt; - } - } - [[nodiscard]] std::unique_ptr<File> OpenFile(const std::string& path, int32_t mode) { int flags; switch (mode) { @@ -289,13 +265,6 @@ jboolean nativeContextUnlink(JNIEnv* env, jclass clazz, jlong ptr, jstring path) return reinterpret_cast<Context*>(ptr)->Unlink(jni::StringToUTF8(env, jni::ParamRef<jstring>(env, path))) ? JNI_TRUE : JNI_FALSE; } -jstring nativeContextReadLink(JNIEnv* env, jclass clazz, jlong ptr, jstring path) { - auto ret = reinterpret_cast<Context*>(ptr)->ReadLink(jni::StringToUTF8(env, jni::ParamRef<jstring>(env, path))); - if (ret.has_value()) - return jni::UTF8ToString(env, ret.value()).release(); - return nullptr; -} - jlong nativeContextOpenFile(JNIEnv* env, jclass clazz, jlong ptr, jstring path, jint mode) { return reinterpret_cast<jlong>(reinterpret_cast<Context*>(ptr)->OpenFile(jni::StringToUTF8(env, jni::ParamRef<jstring>(env, path)), mode).release()); } @@ -382,7 +351,6 @@ void RegisterSamba(JNIEnv* env) { { "nativeContextMakeDir", "(JLjava/lang/String;)Z", reinterpret_cast<void*>(&nativeContextMakeDir) }, { "nativeContextRemoveDir", "(JLjava/lang/String;)Z", reinterpret_cast<void*>(&nativeContextRemoveDir) }, { "nativeContextUnlink", "(JLjava/lang/String;)Z", reinterpret_cast<void*>(&nativeContextUnlink) }, - { "nativeContextReadLink", "(JLjava/lang/String;)Ljava/lang/String;", reinterpret_cast<void*>(&nativeContextReadLink) }, { "nativeContextOpenFile", "(JLjava/lang/String;I)J", reinterpret_cast<void*>(&nativeContextOpenFile) }, { "nativeUrlDestroy", "(J)V", reinterpret_cast<void*>(&nativeUrlDestroy) }, @@ -424,9 +392,6 @@ jni::LocalRef<jobject> CreateDirEntry(JNIEnv* env, const std::string& name, cons case SMB2_TYPE_FILE: type = 1; break; - case SMB2_TYPE_LINK: - type = 2; - break; default: return {env, nullptr}; } |
