Skip to content

Commit 6c6c8ae

Browse files
authored
Add files via upload
1 parent e714818 commit 6c6c8ae

33 files changed

+19781
-0
lines changed

file-system.inc

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
/*
2+
* Copyright (C) 2022 Burak (Nexor)
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
#if defined _PLUGIN_FILE_SYSTEM_
18+
#endinput
19+
#endif
20+
#define _PLUGIN_FILE_SYSTEM_
21+
22+
enum OpenMode
23+
{
24+
ios_base_in, // Open for input operations.
25+
ios_base_out, // Open for output operations.
26+
ios_base_ate, // Set the initial position at the end of the file. If this flag is not set, the initial position is the beginning of the file.
27+
ios_base_app, // All output operations are performed at the end of the file, appending the content to the current content of the file.
28+
ios_base_trunc, // If the file is opened for output operations and it already existed, its previous content is deleted and replaced by the new one.
29+
ios_base_binary // Open in binary mode.
30+
};
31+
32+
enum FileType
33+
{
34+
ft_regular, // Represents a conventional disk file.
35+
ft_directory, // Represents a directory.
36+
ft_symlink, // Represents a symbolic link. (Not supported.)
37+
ft_block, // Represents a block-special file on UNIX-based systems. (Not supported.)
38+
ft_character, // Represents a character-special file on UNIX-based systems. (Not supported.)
39+
ft_fifo, // Represents a FIFO file on UNIX-based systems. (Not supported.)
40+
ft_socket // Represents a socket on UNIX based systems. (Not supported.)
41+
};
42+
43+
enum CopyOptions
44+
{
45+
co_none, // Perform the default behavior for the operation.
46+
co_skip_existing, // Do not copy if the file already exists, do not report an error.
47+
co_overwrite_existing, // Overwrite the file if it already exists.
48+
co_update_existing, // Overwrite the file if it already exists and is older than the replacement.
49+
co_recursive, // Recursively copy subdirectories and their contents.
50+
co_copy_symlinks, // Copy symbolic links as symbolic links, instead of copying the files they point to.
51+
co_skip_symlinks, // Ignore symbolic links.
52+
co_directories_only, // Only iterate over directories, ignore files.
53+
co_create_symlinks, // Make symbolic links instead of copying files. An absolute path must be used as the source path unless the destination is the current directory.
54+
co_create_hard_links // Make hard links instead of copying files.
55+
};
56+
57+
// Log
58+
native FileSystem_EnableLog(bool:enable);
59+
60+
// Directory
61+
native Directory_Exists(const path[]);
62+
native Directory_Create(const path[]);
63+
native Directory_Delete(const path[]);
64+
native Directory_Empty(const path[]);
65+
native Directory_Rename(const old_name[], const new_name[]);
66+
native Directory_CurrentPath(path[], len = sizeof(path));
67+
native Directory_Copy(const from[], const to[], {CopyOptions, _}:...);
68+
native Dir:Directory_Open(const path[] = ".");
69+
native Directory_SetPath(Dir:dir, const path[]);
70+
native Directory_GetPath(Dir:dir, path[], len = sizeof(path));
71+
native Directory_Size(Dir:dir);
72+
native Directory_List(Dir:dir, index, file_name[], full_path[], &file_size, &file_type, len = sizeof(file_name), len2 = sizeof(full_path));
73+
native Directory_Close(Dir:dir);
74+
75+
// File
76+
native File_Exists(const path[]);
77+
native File_Create(const path[], {OpenMode, _}:...);
78+
native File_Delete(const path[]);
79+
native File_Copy(const from[], const to[], {CopyOptions, _}:...);
80+
native File_Rename(const old_name[], const new_name[]);
81+
native File:File_Open(const path[], {OpenMode, _}:...);
82+
native File_Write(File:file, const string[]);
83+
native File_Read(File:file, string[], len = sizeof(string));
84+
native File_Close(File:file);

src/CMakeLists.txt

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
project(file-system)
2+
3+
cmake_minimum_required(VERSION 3.1)
4+
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
5+
6+
include(AMXConfig)
7+
include(AddSAMPPlugin)
8+
9+
include_directories(
10+
${CMAKE_CURRENT_SOURCE_DIR}
11+
${CMAKE_CURRENT_SOURCE_DIR}/amx
12+
)
13+
14+
15+
set(CMAKE_SUPPRESS_REGENERATION true)
16+
set(CMAKE_CXX_STANDARD 17)
17+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
18+
set(CMAKE_CXX_EXTENSIONS OFF)
19+
20+
add_definitions(-DSAMPGDK_AMALGAMATION)
21+
22+
add_samp_plugin(file-system
23+
amxplugin.cpp
24+
compilation-date.hpp
25+
file-system.def
26+
main.cpp
27+
natives.cpp
28+
natives.hpp
29+
plugin.h
30+
plugincommon.h
31+
precompiler.hpp
32+
sampgdk.cpp
33+
sampgdk.hpp
34+
service.cpp
35+
service.hpp
36+
slot-manager.cpp
37+
slot-manager.hpp
38+
utils.cpp
39+
utils.hpp
40+
version.hpp
41+
)

0 commit comments

Comments
 (0)