Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; ===================================================================================
- ; _ _ _ _ _
- ; | | | | |_(_) | ___
- ; | | | | __| | |/ __|
- ; | |_| | |_| | |\__ \
- ; \___/ \__|_|_||___/
- ;
- ; ===================================================================================
- #include <Crypt.au3>
- Func sha1($sFile)
- _Crypt_Startup() ; To optimize performance start the crypt library.
- Local $bHash = _Crypt_HashFile($sFile, $CALG_SHA1) ; Create a hash of the file.
- _Crypt_Shutdown()
- Return StringReplace(String($bHash), "0x", "")
- EndFunc ;==>sha1
- Func tip($sTxt)
- ToolTip($sTxt, 0, 0)
- EndFunc ;==>tip
- Func console($s)
- ConsoleWrite($s&Chr(10))
- EndFunc
- ; ===================================================================================
- ; _____ _ _ ___
- ; | ___(_) | ___ / _ \ _ __ ___ _ __
- ; | |_ | | |/ _ \| | | | '_ \ / _ \| '_ \
- ; | _| | | | __/| |_| | |_) | __/| | | |
- ; |_| |_|_|\___| \___/| .__/ \___||_| |_|
- ; |_|
- ;
- ; ===================================================================================
- #include <File.au3>
- Func initdir($name)
- If Not FileExists($name) Then
- DirCreate($name);
- EndIf
- EndFunc ;==>initdir
- Func stockData($SfilePath, $sTxt);
- Local $Hfile = FileOpen($SfilePath, 2)
- If $Hfile = -1 Then
- _FileCreate($SfilePath)
- FileClose($Hfile)
- $Hfile = FileOpen($SfilePath, 2)
- EndIf
- FileWrite($Hfile, $sTxt)
- FileClose($Hfile)
- EndFunc ;==>stockData
- Func getData($SfilePath, $nbchar = 1);
- Local $Hfile = FileOpen($SfilePath)
- If $Hfile = -1 Then
- _FileCreate($SfilePath)
- FileClose($Hfile)
- Return "";
- EndIf
- Local $Cchars = "";
- While 1
- $Cchars = $Cchars & FileRead($Hfile, 1)
- If @error = -1 Then ExitLoop
- ;MsgBox(0, "Char read:", $Cchars)
- WEnd
- FileClose($Hfile)
- Return $Cchars
- EndFunc ;==>getData
- Func addData($SfilePath, $sTxt);
- Local $Hfile = FileOpen($SfilePath, 1)
- If $Hfile = -1 Then
- _FileCreate($SfilePath)
- FileClose($Hfile)
- $Hfile = FileOpen($SfilePath, 2)
- EndIf
- FileWrite($Hfile, $sTxt)
- FileClose($Hfile)
- EndFunc ;==>addData
- ; ===================================================================================
- ; ____ _ ___ _
- ; / ___|| |_ _ __ ___ __ _ _ __ ___ |_ _|_ __ (_)
- ; \___ \| __| '__|/ _ \ / _` | '_ ` _ \ | || '_ \| |
- ; ___) | |_| | | __/| (_| | | | | | || || | | | |
- ; |____/ \__|_| \___| \__,_|_| |_| |_|___|_| |_|_|
- ; ===================================================================================
- #include <WinAPIFiles.au3>
- Func getIniValue($Ttab, $Skey)
- ;ConsoleWrite("===================="&Chr(10))
- For $i = 1 To $Ttab[0][0]
- ;ConsoleWrite("Key: " & $Ttab[$i][0] & @CRLF & "Value: " & $Ttab[$i][1])
- If $Ttab[$i][0] = $Skey Then
- Return $Ttab[$i][1]
- EndIf
- Next
- ;ConsoleWrite(Chr(10)&"===================="&Chr(10))
- EndFunc ;==>getIniValue
- Func _StreamIniDelete($sSection = "", $sKey = Default, $sStream = "DEFAULT")
- If $sSection = "" Then
- ;completely delete ini file stream through winapi (built in filedelete doesn't support it)
- Return _WinAPI_DeleteFile(_StreamIniPath($sStream, 1))
- Else
- Return IniDelete(_StreamIniPath($sStream, 1), $sSection, $sKey)
- EndIf
- EndFunc ;==>_StreamIniDelete
- Func _StreamIniRead($sSection, $sKey, $sDefault, $sStream = "DEFAULT")
- Return IniRead(_StreamIniPath($sStream, 1), $sSection, $sKey, $sDefault)
- EndFunc ;==>_StreamIniRead
- Func _StreamIniReadSection($sSection, $sStream = "DEFAULT")
- Return IniReadSection(_StreamIniPath($sStream, 1), $sSection)
- EndFunc ;==>_StreamIniReadSection
- Func _StreamIniReadSectionNames($sStream = "DEFAULT")
- Return IniReadSectionNames(_StreamIniPath($sStream, 1))
- EndFunc ;==>_StreamIniReadSectionNames
- Func _StreamIniRenameSection($sSection, $sNewSection, $iFlag = 0, $sStream = "DEFAULT")
- Return IniRenameSection(_StreamIniPath($sStream), $sSection, $sNewSection, $iFlag)
- EndFunc ;==>_StreamIniRenameSection
- Func _StreamIniWrite($sSection, $sKey, $sValue, $sStream = "DEFAULT")
- Return IniWrite(_StreamIniPath($sStream), $sSection, $sKey, $sValue)
- EndFunc ;==>_StreamIniWrite
- Func _StreamIniWriteSection($sSection, $vData, $iIndex = 1, $sStream = "DEFAULT")
- Return IniWriteSection(_StreamIniPath($sStream), $sSection, $vData, $iIndex)
- EndFunc ;==>_StreamIniWriteSection
- Func _StreamIniPath($sStream = "DEFAULT", $iRead = 0)
- Local Static $sBase = ""
- Local $sPath = ""
- If StringLen($sStream) Then
- If $sBase = "" Then
- If DriveGetFileSystem(StringLeft(@ScriptDir, 2)) = "NTFS" Then
- ;current drive is NTFS (supports streams)
- $sBase = @ScriptFullPath
- Else
- ;current drive is not NTFS (no stream support)
- ;fallback to regular path
- $sBase = @TempDir & "\" & @ScriptName
- EndIf
- EndIf
- If $sBase = @ScriptFullPath Then
- $sPath = $sBase & ":" & $sStream
- Else
- ;create directory if necessary
- If Not $iRead And DirGetSize($sBase) = -1 Then DirCreate($sBase)
- $sPath = $sBase & "\" & $sStream & ".ini"
- EndIf
- EndIf
- Return $sPath
- EndFunc ;==>_StreamIniPath
- ; ===================================================================================
Advertisement
Add Comment
Please, Sign In to add comment