{"id":1305,"date":"2018-05-04T19:34:32","date_gmt":"2018-05-04T17:34:32","guid":{"rendered":"http:\/\/blog.m-ri.de\/?p=1305"},"modified":"2018-05-04T08:20:54","modified_gmt":"2018-05-04T06:20:54","slug":"sieh-mal-an-setfilepointer-und-setfilepointerex-sind-eigentlich-ueberfluessig-wenn-man-readfile-und-writefile-verwendet","status":"publish","type":"post","link":"http:\/\/blog.m-ri.de\/index.php\/2018\/05\/04\/sieh-mal-an-setfilepointer-und-setfilepointerex-sind-eigentlich-ueberfluessig-wenn-man-readfile-und-writefile-verwendet\/","title":{"rendered":"Sieh mal an: SetFilePointer und SetFilePointerEx sind eigentlich \u00fcberfl\u00fcssig, wenn man ReadFile und WriteFile verwendet&#8230;"},"content":{"rendered":"<p>Man lernt nie aus, bzw. man hat vermutlich nie die Dokumentation vollst\u00e4ndig und richtig gelesen.<\/p>\n<p>Wenn man eine Datei nicht sequentiell liest ist es normal Seek, Read\/Write in dieser Folge zu nutzen. Order eben <a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/windows\/desktop\/aa365541(v=vs.85).aspx\">SetFilePointer<\/a>, <a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/windows\/desktop\/aa365467(v=vs.85).aspx\">ReadFile<\/a>\/<a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/windows\/desktop\/aa365747(v=vs.85).aspx\">WriteFile<\/a>.<\/p>\n<p>In einer StackOverflow Antwort stolperte ich \u00fcber die Aussage:<\/p>\n<blockquote><p>you not need use\u00a0<code>SetFilePointerEx<\/code>\u00a0&#8211; this is extra call. use explicit offset in\u00a0<code>WriteFile<\/code>\u00a0\/\u00a0<code>ReadFile<\/code>\u00a0instead<\/p><\/blockquote>\n<p>(Rechtschreibung nicht korrigiert).<\/p>\n<p>Aber der Inhalt war f\u00fcr mich neu. Sieh mal an, selbst wen man kein <em>FILE_FLAG_OVERRLAPPED<\/em> benutzt, kann man die <a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/windows\/desktop\/ms684342(v=vs.85).aspx\"><em>OVERLAPPED<\/em><\/a> Struktur nutzen und die darin vorhandenen Offsets verwenden.<br \/>\nDiese werden sogar netterweise angepasst, nachdem gelesen\/geschrieben wurde.<\/p>\n<p>Zitat aus der MSDN (der Text ist gleichlautend f\u00fcr <a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/windows\/desktop\/aa365747(v=vs.85).aspx\">WriteFile<\/a>):<\/p>\n<blockquote><p>Considerations for working with synchronous file handles:<\/p>\n<ul>\n<li>If\u00a0<em>lpOverlapped<\/em>\u00a0is\u00a0<strong>NULL<\/strong>, the read operation starts at the current file position and\u00a0<strong>ReadFile<\/strong>\u00a0does not return until the operation is complete, and the system updates the file pointer before\u00a0<strong>ReadFile<\/strong>\u00a0returns.<\/li>\n<li>If\u00a0<em>lpOverlapped<\/em>\u00a0is not\u00a0<strong>NULL<\/strong>, the read operation starts at the offset that is specified in the\u00a0<a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/windows\/desktop\/ms684342(v=vs.85).aspx\"><strong>OVERLAPPED<\/strong><\/a>\u00a0structure and\u00a0<strong>ReadFile<\/strong>\u00a0does not return until the read operation is complete. The system updates the\u00a0<strong>OVERLAPPED<\/strong>\u00a0offset before\u00a0<strong>ReadFile<\/strong>\u00a0returns.<\/li>\n<\/ul>\n<\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>Man lernt nie aus, bzw. man hat vermutlich nie die Dokumentation vollst\u00e4ndig und richtig gelesen. Wenn man eine Datei nicht sequentiell liest ist es normal Seek, Read\/Write in dieser Folge zu nutzen. Order eben SetFilePointer, ReadFile\/WriteFile. In einer StackOverflow Antwort stolperte ich \u00fcber die Aussage: you not need use\u00a0SetFilePointerEx\u00a0&#8211; this is extra call. use explicit &hellip; <a href=\"http:\/\/blog.m-ri.de\/index.php\/2018\/05\/04\/sieh-mal-an-setfilepointer-und-setfilepointerex-sind-eigentlich-ueberfluessig-wenn-man-readfile-und-writefile-verwendet\/\" class=\"more-link\"><span class=\"screen-reader-text\">\u201eSieh mal an: SetFilePointer und SetFilePointerEx sind eigentlich \u00fcberfl\u00fcssig, wenn man ReadFile und WriteFile verwendet&#8230;\u201c <\/span>weiterlesen<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[3,393,2],"tags":[394,59,61],"class_list":["post-1305","post","type-post","status-publish","format-standard","hentry","category-programmieren","category-sieh-mal-an","category-windows-api","tag-sieh-mal-an","tag-win32","tag-winapi"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"http:\/\/blog.m-ri.de\/index.php\/wp-json\/wp\/v2\/posts\/1305","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/blog.m-ri.de\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/blog.m-ri.de\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/blog.m-ri.de\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/blog.m-ri.de\/index.php\/wp-json\/wp\/v2\/comments?post=1305"}],"version-history":[{"count":0,"href":"http:\/\/blog.m-ri.de\/index.php\/wp-json\/wp\/v2\/posts\/1305\/revisions"}],"wp:attachment":[{"href":"http:\/\/blog.m-ri.de\/index.php\/wp-json\/wp\/v2\/media?parent=1305"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/blog.m-ri.de\/index.php\/wp-json\/wp\/v2\/categories?post=1305"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/blog.m-ri.de\/index.php\/wp-json\/wp\/v2\/tags?post=1305"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}