[Feature Request] Convert from Valve filesystem search paths
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 35/100
Hướng nghiên cứu
The issue does not name implementation files or tests. Start by locating the Valve filesystem search-path handling and the OpenFile API in the SourceMod codebase, then trace how writable modes resolve files. Done means providing a way to find real paths for Valve search-path files so callers can open them for writing; the issue gives no specific test target.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Help us help you
- I have checked that my issue doesn't exist yet.
- I have tried my absolute best to reduce the problem-space and have provided the absolute smallest test-case possible.
- I can always reproduce the issue with the provided description below.
Environment
- Operating System version: Windows 11
- Game/AppID (with version if applicable): hl2dm
- Current SourceMod version: 1.12.0.7031
Description
While reading a file from the custom folder using Valve filesystem is effortless, as soon as you try opening it with a mode that is able to write, the file is not found. As far as I understand, this is a Valve limitation.
For a workaround (and other use cases) I suggest adding a function that either
- Returns all Valve search paths as real paths, so we can iterate over them
- Finds occurrences of a file in Valve FS and returns its real paths.
That way we can open the files for writing with normal filesystem.
Problematic Code (or Steps to Reproduce)
// custom/test/maps/myconfig.txt
OpenFile("maps/myconfig.txt", "r", true); // valid
OpenFile("maps/myconfig.txt", "r+", true); // null
OpenFile("custom/test/maps/myconfig.txt", "r+") // valid
SP workaround:
/**
* This is a workaround for opening existing files, potentially located in the custom folder, with the Valve filesystem, for both reading and writing.
* Normally, opening an existing file with Valve FS using any writable modes ("r+", "a", ..) will only look for files in root game folder.
* This function currently accounts for the custom folder only, other additional Valve search paths are ignored.
*
* https://github.com/alliedmodders/sourcemod/issues/2175
*/
stock File OpenFileEx(const char[] file, const char[] mode, bool use_valve_fs=false, const char[] valve_path_id="GAME")
{
if (use_valve_fs && !StrEqual(mode, "r", false) && !StrEqual(mode, "rb", false) && !StrEqual(mode, "rt", false))
{
char szFullPath[PLATFORM_MAX_PATH];
if (ResolveValveFile(file, szFullPath, sizeof(szFullPath)))
{
return OpenFile(szFullPath, mode);
}
}
return OpenFile(file, mode, use_valve_fs, valve_path_id);
}
/**
* Should only be used as last resort.
*/
stock bool ResolveValveFile(const char[] szFile, char[] szFullPath, int maxLen)
{
DirectoryListing dir = OpenDirectory("custom");
if (dir)
{
char buffer[PLATFORM_MAX_PATH];
FileType ft;
while (dir.GetNext(buffer, sizeof(buffer), ft))
{
if (ft == FileType_Directory && !StrEqual(buffer, ".") && !StrEqual(buffer, ".."))
{
Format(buffer, sizeof(buffer), "custom/%s/%s", buffer, szFile);
if (FileExists(buffer))
{
dir.Close();
Format(szFullPath, maxLen, buffer);
return true;
}
}
}
dir.Close();
}
return false;
}
- Ngôn ngữ chính
- C++
- Star
- 1.2k
- Fork
- 476
- Merge trung bình
- 2 ngày 9 giờ
- Pull request đã merge (30 ngày)
- 13
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của alliedmodders/sourcemod
-
[Bug]: RoundToNearest truncates in plugins compiled with spcomp 1.13Có thể đã có người làm @fmu1337 đã nhận hôm nay. Đang mởBug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
alliedmodders/sourcemod#2627 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
alliedmodders/sourcemod#2615 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
alliedmodders/sourcemod#2613 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
alliedmodders/sourcemod#2571 · 4 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Disable Nextmap for CSGO?Đang mởFeature Request
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 64/100
alliedmodders/sourcemod#2555 · 3 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của alliedmodders/sourcemod
Issue tương tự
-
enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
raspberrypi/rpi-imager#1804 ·
-
difficulty: easy docs good first issue help wanted
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
Ryan-Millard/Img2Num#842 ·
Maintainer thường phản hồi trong vòng 12 ngày
-
Unit converter reads out of bounds when the saved UnitConverterPreferences setting is malformedĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
microsoft/calculator#2532 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 64/100
-
bug difficulty:easy prio:normal
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
NatronGitHub/openfx-misc#411 ·
Maintainer thường phản hồi trong vòng 1 ngày