<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Серый форум &mdash; AHK: Дата изменения файла на FTP Сервере.]]></title>
	<link rel="self" href="http://forum.script-coding.com/extern.php?action=feed&amp;tid=18309&amp;type=atom" />
	<updated>2024-10-06T15:24:27Z</updated>
	<generator>PunBB</generator>
	<id>http://forum.script-coding.com/viewtopic.php?id=18309</id>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Дата изменения файла на FTP Сервере.]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=161660#p161660" />
			<content type="html"><![CDATA[<p><strong>teadrinker</strong> Благодарю за уделенное время, я решил задачу с помощью другой функции.<br /></p><div class="codebox"><pre><code>hFTP := FTP.Open(&quot;AHK-FTP&quot;)
hSession := FTP.Connect(hFTP, &quot;Serv&quot;, 21, &quot;Name&quot;, &quot;Passw&quot;)
for k, File in FTP.FindFiles(hSession,&quot;/upload/Soft/1.txt&quot;)
MsgBox % &quot;&quot;
   . &quot;`nИмя файла : &quot; . File.FileName
   . &quot;`nДата изменения файла : &quot; . File.LastWriteTime
FTP.Disconnect(hSession)
FTP.Close(hFTP)

#Include FTP.ahk</code></pre></div>]]></content>
			<author>
				<name><![CDATA[anreichxxx@mail.ru]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=43543</uri>
			</author>
			<updated>2024-10-06T15:24:27Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=161660#p161660</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Дата изменения файла на FTP Сервере.]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=161659#p161659" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>teadrinker пишет:</cite><blockquote><p>Почему думаете, что они неверные?</p></blockquote></div><p>CreationTime и LastAccessTime&nbsp; показывают 1601 год ну это ладно , оно и не должно работать,<br />LastWriteTime показывает 2024 год и время , но это время не привязано к файлам и папкам.<br />Вчера страдал с этим ftp и сегодня закинул файл, а сейчас показывает время&nbsp; 2024 10.05 19:40. <br />Странно , у меня нет на сервере файлов с таким временем.</p>]]></content>
			<author>
				<name><![CDATA[anreichxxx@mail.ru]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=43543</uri>
			</author>
			<updated>2024-10-06T13:26:44Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=161659#p161659</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Дата изменения файла на FTP Сервере.]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=161658#p161658" />
			<content type="html"><![CDATA[<p>С виду в коде всё правильно. А какие значения вы получаете, и почему думаете, что они неверные?</p>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2024-10-06T11:26:01Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=161658#p161658</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Дата изменения файла на FTP Сервере.]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=161655#p161655" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>teadrinker пишет:</cite><blockquote><p>Наверно зависит от библиотеки FTP.ahk, вы её не предоставили.</p></blockquote></div><div class="codebox"><pre><code>class FTP
{

	static hWININET := DllCall(&quot;LoadLibrary&quot;, &quot;str&quot;, &quot;wininet.dll&quot;, &quot;ptr&quot;)


	; ===== PUBLIC METHODS ======================================================================================================

	Close(hInternet)
	{
		if (hInternet)
			if (this.InternetCloseHandle(hInternet))
				return true
		return false
	}


	Connect(hInternet, ServerName, Port := 21, UserName := &quot;&quot;, Password := &quot;&quot;, FTP_PASV := 1)
	{
		if (hConnect := this.InternetConnect(hInternet, ServerName, Port, UserName, Password, FTP_PASV))
			return hConnect
		return false
	}


	CreateDirectory(hConnect, Directory)
	{
		if (DllCall(&quot;wininet\FtpCreateDirectory&quot;, &quot;ptr&quot;, hConnect, &quot;ptr&quot;, &amp;Directory))
			return true
		return false
	}


	DeleteFile(hConnect, FileName)
	{
		if (DllCall(&quot;wininet\FtpDeleteFile&quot;, &quot;ptr&quot;, hConnect, &quot;ptr&quot;, &amp;FileName))
			return true
		return false
	}


	Disconnect(hConnect)
	{
		if (hConnect)
			if (this.InternetCloseHandle(hConnect))
				return true
		return false
	}


	FindFiles(hConnect, SearchFile := &quot;*.*&quot;)
	{
		static FILE_ATTRIBUTE_DIRECTORY := 0x10

		Files := []
		find := this.FindFirstFile(hConnect, hEnum, SearchFile)
		if !(find.FileAttr &amp; FILE_ATTRIBUTE_DIRECTORY)
			Files.Push(find)

		while (find := this.FindNextFile(hEnum))
			if !(find.FileAttr &amp; FILE_ATTRIBUTE_DIRECTORY)
				Files.Push(find)
		this.Close(hEnum)
		return Files
	}


	FindFolders(hConnect, SubDirectories := &quot;*.*&quot;)
	{
		static FILE_ATTRIBUTE_DIRECTORY := 0x10

		Folders := []
		find := this.FindFirstFile(hConnect, hEnum, SubDirectories)
		if (find.FileAttr &amp; FILE_ATTRIBUTE_DIRECTORY)
			Folders.Push(find)
		while (find := this.FindNextFile(hEnum))
			if (find.FileAttr &amp; FILE_ATTRIBUTE_DIRECTORY)
				Folders.Push(find)
		this.Close(hEnum)
		return Folders
	}


	GetCurrentDirectory(hConnect)
	{
		static MAX_PATH := 260 + 8

		BUFFER_SIZE := VarSetCapacity(CurrentDirectory, MAX_PATH, 0)
		if (DllCall(&quot;wininet\FtpGetCurrentDirectory&quot;, &quot;ptr&quot;, hConnect, &quot;ptr&quot;, &amp;CurrentDirectory, &quot;uint*&quot;, BUFFER_SIZE))
			return StrGet(&amp;CurrentDirectory)
		return false
	}


	GetFile(hConnect, RemoteFile, NewFile, OverWrite := 0, Flags := 0)
	{
		if (DllCall(&quot;wininet\FtpGetFile&quot;, &quot;ptr&quot;, hConnect, &quot;ptr&quot;, &amp;RemoteFile, &quot;ptr&quot;, &amp;NewFile, &quot;int&quot;, !OverWrite, &quot;uint&quot;, 0, &quot;uint&quot;, Flags, &quot;uptr&quot;, 0))
			return true
		return false
	}


	GetFileSize(hConnect, FileName, SizeFormat := &quot;auto&quot;, SizeSuffix := false)
	{
		static GENERIC_READ := 0x80000000

		if (hFile := this.OpenFile(hConnect, FileName, GENERIC_READ))
		{
			VarSetCapacity(FileSizeHigh, 8)
			if (FileSizeLow := DllCall(&quot;wininet\FtpGetFileSize&quot;, &quot;ptr&quot;, hFile, &quot;uint*&quot;, FileSizeHigh, &quot;uint&quot;))
			{
				this.InternetCloseHandle(hFile)
				return this.FormatBytes(FileSizeLow + (FileSizeHigh &lt;&lt; 32), SizeFormat, SizeSuffix)
			}
			this.InternetCloseHandle(hFile)
		}
		return false
	}


	Open(Agent, Proxy := &quot;&quot;, ProxyBypass := &quot;&quot;)
	{
		if (hInternet := this.InternetOpen(Agent, Proxy, ProxyBypass))
			return hInternet
		return false
	}


	PutFile(hConnect, LocaleFile, RemoteFile, Flags := 0)
	{
		if (DllCall(&quot;wininet\FtpPutFile&quot;, &quot;ptr&quot;, hConnect, &quot;ptr&quot;, &amp;LocaleFile, &quot;ptr&quot;, &amp;RemoteFile, &quot;uint&quot;, Flags, &quot;uptr&quot;, 0))
			return true
		return false
	}


	RemoveDirectory(hConnect, Directory)
	{
		if (DllCall(&quot;wininet\FtpRemoveDirectory&quot;, &quot;ptr&quot;, hConnect, &quot;ptr&quot;, &amp;Directory))
			return true
		return false
	}


	RenameFile(hConnect, ExistingFile, NewFile)
	{
		if (DllCall(&quot;wininet\FtpRenameFile&quot;, &quot;ptr&quot;, hConnect, &quot;ptr&quot;, &amp;ExistingFile, &quot;ptr&quot;, &amp;NewFile))
			return true
		return false
	}


	SetCurrentDirectory(hconnect, Directory)
	{
		if (DllCall(&quot;wininet\FtpSetCurrentDirectory&quot;, &quot;ptr&quot;, hConnect, &quot;ptr&quot;, &amp;Directory))
			return true
		return false
	}


	; ===== PRIVATE METHODS =====================================================================================================

	FileAttributes(Attributes)
	{
		static FILE_ATTRIBUTE := { 0x1: &quot;READONLY&quot;, 0x2: &quot;HIDDEN&quot;, 0x4: &quot;SYSTEM&quot;, 0x10: &quot;DIRECTORY&quot;, 0x20: &quot;ARCHIVE&quot;, 0x40: &quot;DEVICE&quot;, 0x80: &quot;NORMAL&quot;
						, 0x100: &quot;TEMPORARY&quot;, 0x200: &quot;SPARSE_FILE&quot;, 0x400: &quot;REPARSE_POINT&quot;, 0x800: &quot;COMPRESSED&quot;, 0x1000: &quot;OFFLINE&quot;
						, 0x2000: &quot;NOT_CONTENT_INDEXED&quot;, 0x4000: &quot;ENCRYPTED&quot;, 0x8000: &quot;INTEGRITY_STREAM&quot;, 0x10000: &quot;VIRTUAL&quot;
						, 0x20000: &quot;NO_SCRUB_DATA&quot;, 0x40000: &quot;RECALL_ON_OPEN&quot;, 0x400000: &quot;RECALL_ON_DATA_ACCESS&quot; }
		GetFileAttributes := []
		for k, v in FILE_ATTRIBUTE
			if (k &amp; Attributes)
				GetFileAttributes.Push(v)
		return GetFileAttributes
	}


	FindData(ByRef WIN32_FIND_DATA, SizeFormat := &quot;auto&quot;, SizeSuffix := false)
	{
		static MAX_PATH := 260
		static MAXDWORD := 0xffffffff

		addr := &amp;WIN32_FIND_DATA
		FIND_DATA := []
		FIND_DATA[&quot;FileAttr&quot;]          := NumGet(addr + 0, &quot;uint&quot;)
		FIND_DATA[&quot;FileAttributes&quot;]    := this.FileAttributes(NumGet(addr + 0, &quot;uint&quot;))
		FIND_DATA[&quot;CreationTime&quot;]      := this.FileTime(NumGet(addr +  4, &quot;uint64&quot;))
		FIND_DATA[&quot;LastAccessTime&quot;]    := this.FileTime(NumGet(addr + 12, &quot;uint64&quot;))
		FIND_DATA[&quot;LastWriteTime&quot;]     := this.FileTime(NumGet(addr + 20, &quot;uint64&quot;))
		FIND_DATA[&quot;FileSize&quot;]          := this.FormatBytes((NumGet(addr + 28, &quot;uint&quot;) * (MAXDWORD + 1)) + NumGet(addr + 32, &quot;uint&quot;), SizeFormat, SizeSuffix)
		FIND_DATA[&quot;FileName&quot;]          := StrGet(addr + 44, &quot;utf-16&quot;)
		FIND_DATA[&quot;AlternateFileName&quot;] := StrGet(addr + 44 + MAX_PATH * (A_IsUnicode ? 2 : 1), &quot;utf-16&quot;)
		return FIND_DATA
	}


	FindFirstFile(hConnect, ByRef hFind, SearchFile := &quot;*.*&quot;, SizeFormat := &quot;auto&quot;, SizeSuffix := false)
	{
		VarSetCapacity(WIN32_FIND_DATA, (A_IsUnicode ? 592 : 320), 0)
		if (hFind := DllCall(&quot;wininet\FtpFindFirstFile&quot;, &quot;ptr&quot;, hConnect, &quot;str&quot;, SearchFile, &quot;ptr&quot;, &amp;WIN32_FIND_DATA, &quot;uint&quot;, 0, &quot;uint*&quot;, 0))
			return this.FindData(WIN32_FIND_DATA, SizeFormat, SizeSuffix)
		VarSetCapacity(WIN32_FIND_DATA, 0)
		return false
	}


	FindNextFile(hFind, SearchFile := &quot;*.*&quot;, SizeFormat := &quot;auto&quot;, SizeSuffix := false)
	{
		VarSetCapacity(WIN32_FIND_DATA, (A_IsUnicode ? 592 : 320), 0)
		if (DllCall(&quot;wininet\InternetFindNextFile&quot;, &quot;ptr&quot;, hFind, &quot;ptr&quot;, &amp;WIN32_FIND_DATA))
			return this.FindData(WIN32_FIND_DATA, SizeFormat, SizeSuffix)
		VarSetCapacity(WIN32_FIND_DATA, 0)
		return false
	}


	FileTime(addr)
	{
		this.FileTimeToSystemTime(addr, SystemTime)
		this.SystemTimeToTzSpecificLocalTime(&amp;SystemTime, LocalTime)
		return Format(&quot;{:04}{:02}{:02}{:02}{:02}{:02}&quot;
					, NumGet(LocalTime,  0, &quot;ushort&quot;)
					, NumGet(LocalTime,  2, &quot;ushort&quot;)
					, NumGet(LocalTime,  6, &quot;ushort&quot;)
					, NumGet(LocalTime,  8, &quot;ushort&quot;)
					, NumGet(LocalTime, 10, &quot;ushort&quot;)
					, NumGet(LocalTime, 12, &quot;ushort&quot;))
	}


	FileTimeToSystemTime(FileTime, ByRef SystemTime)
	{
		VarSetCapacity(SystemTime, 16, 0)
		if (DllCall(&quot;FileTimeToSystemTime&quot;, &quot;int64*&quot;, FileTime, &quot;ptr&quot;, &amp;SystemTime))
			return true
		return false
	}


	FormatBytes(bytes, SizeFormat := &quot;auto&quot;, suffix := false)
	{
		static SFBS_FLAGS_ROUND_TO_NEAREST_DISPLAYED_DIGIT    := 0x0001
		static SFBS_FLAGS_TRUNCATE_UNDISPLAYED_DECIMAL_DIGITS := 0x0002
		static S_OK := 0

		if (SizeFormat = &quot;auto&quot;)
		{
			size := VarSetCapacity(buf, 1024, 0)
			if (DllCall(&quot;shlwapi\StrFormatByteSizeEx&quot;, &quot;int64&quot;, bytes, &quot;int&quot;, SFBS_FLAGS_ROUND_TO_NEAREST_DISPLAYED_DIGIT, &quot;str&quot;, buf, &quot;uint&quot;, size) = S_OK)
				output := buf
		}
		else if (SizeFormat = &quot;kilobytes&quot; || SizeFormat = &quot;kb&quot;)
			output := Round(bytes / 1024, 2) . (suffix ? &quot; KB&quot; : &quot;&quot;)
		else if (SizeFormat = &quot;megabytes&quot; || SizeFormat = &quot;mb&quot;)
			output := Round(bytes / 1024**2, 2) . (suffix ? &quot; MB&quot; : &quot;&quot;)
		else if (SizeFormat = &quot;gigabytes&quot; || SizeFormat = &quot;gb&quot;)
			output := Round(bytes / 1024**3, 2) . (suffix ? &quot; GB&quot; : &quot;&quot;)
		else if (SizeFormat = &quot;terabytes&quot; || SizeFormat = &quot;tb&quot;)
			output := Round(bytes / 1024**4, 2) . (suffix ? &quot; TB&quot; : &quot;&quot;)
		else
			output := Round(bytes, 2) . (suffix ? &quot; Bytes&quot; : &quot;&quot;)
		return output
	}


	InternetCloseHandle(hInternet)
	{
		if (DllCall(&quot;wininet\InternetCloseHandle&quot;, &quot;ptr&quot;, hInternet))
			return true
		return false
	}


	InternetConnect(hInternet, ServerName, Port := 21, UserName := &quot;&quot;, Password := &quot;&quot;, FTP_PASV := 1)
	{
		static INTERNET_DEFAULT_FTP_PORT := 21
		static INTERNET_SERVICE_FTP      := 1
		static INTERNET_FLAG_PASSIVE     := 0x08000000

		if (hConnect := DllCall(&quot;wininet\InternetConnect&quot;, &quot;ptr&quot;,    hInternet
		                                                 , &quot;ptr&quot;,    &amp;ServerName
		                                                 , &quot;ushort&quot;, (Port = 21 ? INTERNET_DEFAULT_FTP_PORT : Port)
		                                                 , &quot;ptr&quot;,    (UserName ? &amp;UserName : 0)
		                                                 , &quot;ptr&quot;,    (Password ? &amp;Password : 0)
		                                                 , &quot;uint&quot;,   INTERNET_SERVICE_FTP
		                                                 , &quot;uint&quot;,   (FTP_PASV ? INTERNET_FLAG_PASSIVE : 0)
		                                                 , &quot;uptr&quot;,   0
		                                                 , &quot;ptr&quot;))
			return hConnect
		return false
	}


	InternetOpen(Agent, Proxy := &quot;&quot;, ProxyBypass := &quot;&quot;)
	{
		static INTERNET_OPEN_TYPE_DIRECT := 1
		static INTERNET_OPEN_TYPE_PROXY  := 3

		if (hInternet := DllCall(&quot;wininet\InternetOpen&quot;, &quot;ptr&quot;,  &amp;Agent
		                                               , &quot;uint&quot;, (Proxy ? INTERNET_OPEN_TYPE_PROXY : INTERNET_OPEN_TYPE_DIRECT)
		                                               , &quot;ptr&quot;,  (Proxy ? &amp;Proxy : 0)
		                                               , &quot;ptr&quot;,  (ProxyBypass ? &amp;ProxyBypass : 0)
		                                               , &quot;uint&quot;, 0
		                                               , &quot;ptr&quot;))
			return hInternet
		return false
	}


	OpenFile(hConnect, FileName, Access)
	{
		static FTP_TRANSFER_TYPE_BINARY := 2

		if (hFTPSESSION := DllCall(&quot;wininet\FtpOpenFile&quot;, &quot;ptr&quot;, hConnect, &quot;ptr&quot;, &amp;FileName, &quot;uint&quot;, Access, &quot;uint&quot;, FTP_TRANSFER_TYPE_BINARY, &quot;uptr&quot;, 0))
			return hFTPSESSION
		return false
	}


	SystemTimeToTzSpecificLocalTime(SystemTime, ByRef LocalTime)
	{
		VarSetCapacity(LocalTime, 16, 0)
		if (DllCall(&quot;SystemTimeToTzSpecificLocalTime&quot;, &quot;ptr&quot;, 0, &quot;ptr&quot;, SystemTime, &quot;ptr&quot;, &amp;LocalTime))
			return true
		return false
	}

}

; ===============================================================================================================================</code></pre></div>]]></content>
			<author>
				<name><![CDATA[anreichxxx@mail.ru]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=43543</uri>
			</author>
			<updated>2024-10-06T05:31:55Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=161655#p161655</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Дата изменения файла на FTP Сервере.]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=161654#p161654" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>anreichxxx@mail.ru пишет:</cite><blockquote><p>как получить дату загрузки</p></blockquote></div><p>Наверно зависит от библиотеки FTP.ahk, вы её не предоставили.</p>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2024-10-05T18:09:28Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=161654#p161654</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[AHK: Дата изменения файла на FTP Сервере.]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=161653#p161653" />
			<content type="html"><![CDATA[<p>Здравствуйте, несколько дней ищу ответ как получить дату загрузки, изменения файла на сервере FTP.<br />Знания у меня довольно низкие пытался пользваться готовыми примерами.<br />В единственном случае удалось получить дату , но это просто случайные даты, прошу совета.<br /></p><div class="codebox"><pre><code>hFTP := FTP.Open(&quot;AHK-FTP&quot;)
hSession := FTP.Connect(hFTP, &quot;Serv &quot;, 21, &quot;Name &quot;, &quot;Passw&quot;)  
item := FTP.FindFirstFile(hSession,&quot;/upload/1.txt&quot;) ;FTP.FindFirstFile
MsgBox % &quot;Name : &quot; . item.Name
 . &quot;`nCreationTime : &quot; . item.CreationTime
 . &quot;`nLastAccessTime : &quot; . item.LastAccessTime
 . &quot;`nLastWriteTime : &quot; . item.LastWriteTime
FTP.Disconnect(hSession)
FTP.Close(hFTP)

#Include FTP.ahk</code></pre></div>]]></content>
			<author>
				<name><![CDATA[anreichxxx@mail.ru]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=43543</uri>
			</author>
			<updated>2024-10-05T11:00:17Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=161653#p161653</id>
		</entry>
</feed>
