module load: attempt to load modules from /vendor

Use TW_LOAD_VENDOR_MODULES := "module1.ko module2.ko modulen.ko"
in BoardConfig to have TWRP attempt to load kernel modules during
startup. For fastboot ramdisks, TWRP will attempt to load from
the ramdisk from /vendor/lib/modules. You can have the build
system copy the modules to
$(TARGET_RECOVERY_ROOT_OUT)/vendor/lib/modules/1.1
Otherwise in recovery in boot mode, TWRP will attempt the following:
check /lib/modules (ramdisk vendor_boot)
check /lib/modules/N.N (ramdisk vendor_boot)
check /lib/modules/N.N-gki (ramdisk vendor_boot)
check /vendor/lib/modules (ramdisk)
check /vendor/lib/modules/1.1 (ramdisk prebuilt modules)
check /vendor/lib/modules/N.N (vendor mounted)
check /vendor/lib/modules/N.N-gki (vendor mounted)

Change-Id: I2dccf199e37d47cb7a7e79b0e11026d67b4e3186
diff --git a/twrp-functions.hpp b/twrp-functions.hpp
index dc51454..77ca1a2 100755
--- a/twrp-functions.hpp
+++ b/twrp-functions.hpp
@@ -30,8 +30,8 @@
 
 using namespace std;
 
-#define CACHE_LOGS_DIR "/cache/"		// For devices with a dedicated cache partition
-#define DATA_LOGS_DIR "/data/"			// For devices that do not have a dedicated cache partition
+#define CACHE_LOGS_DIR "/cache/" // For devices with a dedicated cache partition
+#define DATA_LOGS_DIR "/data/"	 // For devices that do not have a dedicated cache partition
 
 typedef enum
 {
@@ -87,12 +87,13 @@
 	static int tw_reboot(RebootCommand command);                                // Prepares the device for rebooting
 	static void check_and_run_script(const char* script_file, const char* display_name); // checks for the existence of a script, chmods it to 755, then runs it
 	static int removeDir(const string path, bool removeParent); //recursively remove a directory
-	static int copy_file(string src, string dst, int mode); //copy file from src to dst with mode permissions
+	static int copy_file(string src, string dst, int mode, bool mount_paths=true); //copy file from src to dst with mode permissions
 	static unsigned int Get_D_Type_From_Stat(string Path);                      // Returns a dirent dt_type value using stat instead of dirent
 	static int read_file(string fn, vector<string>& results); //read from file
 	static int read_file(string fn, string& results); //read from file
 	static int read_file(string fn, uint64_t& results); //read from file
-	static int write_to_file(const string& fn, const string& line);             //write to file
+	static bool write_to_file(const string& fn, const string& line);              //write single line to file with no newline
+	static bool write_to_file(const string& fn, const std::vector<string> lines); // write vector of strings line by line with newlines
 	static bool Try_Decrypting_Backup(string Restore_Path, string Password); // true for success, false for failed to decrypt
 	static string System_Property_Get(string Prop_Name);                // Returns value of Prop_Name from reading /system/build.prop
 	static string System_Property_Get(string Prop_Name, TWPartitionManager &PartitionManager, string Mount_Point);                // Returns value of Prop_Name from reading /system/build.prop
@@ -125,9 +126,9 @@
 	static bool Set_Encryption_Policy(std::string path, struct fscrypt_policy_v2 &policy); // set encryption policy for path
 #endif
 #endif
-	static void List_Mounts();
-	static void Clear_Bootloader_Message();
-	static string Check_For_TwrpFolder();
+	static void List_Mounts(); // List current mounts by the kernel
+	static void Clear_Bootloader_Message(); // Removes the bootloader message from misc for next boot
+	static string Check_For_TwrpFolder(); // Gets user defined path on storage where backups should be stored
 
 private:
 	static void Copy_Log(string Source, string Destination);