1 / 13

Įvedimo ir išvedimo operacijos: darbas su failais

Įvedimo ir išvedimo operacijos: darbas su failais. Martynas Maciulevičius IT2. Turinys. Failai „Windows“ sistemoje (GUI) Failai „Windows API“ Paprastas failų IO Memmory-Mapped failų IO Asinchroninis failų IO Handle. Failai „Windows“ sistemoje. Failų tipai Failų atributai a . txt.

helki
Download Presentation

Įvedimo ir išvedimo operacijos: darbas su failais

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Įvedimo ir išvedimo operacijos: darbas su failais Martynas Maciulevičius IT2

  2. Turinys • Failai „Windows“ sistemoje (GUI) • Failai „Windows API“ • Paprastas failų IO • Memmory-Mapped failų IO • Asinchroninis failų IO • Handle

  3. Failai „Windows“ sistemoje • Failų tipai • Failų atributai a.txt

  4. Handle‘ai • Handle – abstrakti nuoroda į resursą • Handle naudojimas Windows’uose Le handle

  5. Handle naudojimas DWORD WINAPIGetFileSize( HANDLEhFile, -LPDWORDlpFileSizeHigh );

  6. Failų kūrimas HANDLE WINAPICreateFile( LPCTSTR lpFileName, DWORD dwDesiredAccess, //rwx DWORD dwShareMode, //rw0 - LPSECURITY_ATTRIBUTES lpSecurityAttributes, DWORD dwCreationDisposition, //-> DWORD dwFlagsAndAttributes, //->> - HANDLE hTemplateFile );

  7. DWORD dwCreationDisposition • CREATE_ALWAYS • CREATE_NEW • OPEN_ALWAYS • OPEN_EXISTING • TRUNCATE_EXISTING //(only with w)

  8. DWORD dwFlagsAndAttributes • FILE_ATTRIBUTE_HIDDEN • FILE_ATTRIBUTE_NORMAL • FILE_ATTRIBUTE_READONLY • FILE_ATTRIBUTE_TEMPORARY • ...

  9. Failo skaitymas / rašymas BOOL WINAPI WriteFile( //ReadFile HANDLE hFile, LPCVOID lpBuffer, // buferis DWORD nNumberOfBytesToWrite, // Read - LPDWORD lpNumberOfBytesWritten,// Read - LPOVERLAPPED lpOverlapped );

  10. Failo uždarymas BOOL WINAPI CloseHandle( HANDLEhObject );

  11. Memmory-Mapped būdas • Nuskaitomas pilnas failas • Reikšmės atmintyje pakeičiamos • Įrašoma • Gerai ar blogai?

  12. Overlapped skaitymo būdas • Sinchroninis: kai skaitoma paprastai // up • Asinchroninis: „užsakoma“ ir po nuskaitymo gaunamas pranešimas • BOOL WINAPI WriteFile( //ReadFile HANDLE hFile, LPCVOID lpBuffer, DWORD nNumberOfBytesToWrite, LPDWORD lpNumberOfBytesWritten, • LPOVERLAPPED lpOverlapped ); H ->

  13. Klausimai

More Related