Programowanie w systemie UNIX/pliki

Z Wikibooks, biblioteki wolnych podręczników.
 "Kompletne dzieła Szekspira, nieskompresowane, zajmują mniej więcej tyle samo miejsca, co 2 typowe zdjęcia zrobione nowoczesnym smartfonem (~5 megabajtów)."[1]

Typy[edytuj]

Pliki[2]

  • podział klasyczny
  • podział wg MIME
    • application
    • audio
    • font
    • example
    • image
    • message
    • model
    • multipart
    • text
    • video

MIME[edytuj]

Media type, zwany także typem MIME (od ang. Multipurpose Internet Mail Extensions) oraz czasem Content-Type (po nazwie nagłówka kilku protokołów, którego wartość jest tego typu) – dwuczęściowy identyfikator formatu plików i formatu treści przesyłanych w Internecie[3]


Ustawienia[edytuj]

Plik z ustawieniami: /etc/mime.types

###############################################################################
#
#  Media (MIME) types and the extensions that represent them.
#
#  The format of this file is a media type on the left and zero or more
#  filename extensions on the right.  Programs using this file will map
#  files ending with those extensions to the associated type.
#
#  This file is part of the "media-types" package.  Please report a bug using
#  the "reportbug" command of the "reportbug" package if you would like new
#  types or extensions to be added.
#
#  The reason that all types are managed by the media-types package instead
#  allowing individual packages to install types in much the same way as they
#  add entries in to the mailcap file is so these types can be referenced by
#  other programs (such as a web server) even if the specific support package
#  for that type is not installed.
#
#  Users can add their own types if they wish by creating a ".mime.types"
#  file in their home directory.  Definitions included there will take
#  precedence over those listed here.
#
###############################################################################

sprawdzanie[edytuj]

Sprawdzamy typ pliku wg MIME: [4]

 xdg-mime query filetype a.txt

Tutaj "a.txt" jest istniejącym, konkretnym plikiem. Wynik:

text/plain

Sprawdzamy jaka jest domyślna aplikacja do otwarcia pliku typu pdf

xdg-mime query default application/pdf

Przykładowa odpowiedź:

FoxitReader.desktop

Ustawienie domyślnej aplikacji:

  • zainstalowanie aplikacji
  • utworzenie pliku desktop w katalogu ~/.local/share/applications
  • wpis do bazy danych ( /etc/mime.types) , uaktualnienie
  • sprawdzenie


update-mime-database ~/.local/share/mime


otwieranie[edytuj]

Otwórz bieżący katalog w domyślnym eksploratorze plików:[5]

xdg-open .

Suma kontrolna[edytuj]


Żródła[edytuj]

  1. quora: What-s-something-a-computer-programmer-knows-that-would-amaze-people-who-use-computers
  2. what-are-binary-and-text-files by Nayuki
  3. Typ_MIME w wikipedii
  4. stackoverflow question: how-to-use-the-xdg-mime-command
  5. linuxcommandlibrary : xdg-open
  6. unix.stackexchange question: why-are-end-of-file-and-end-of-input-signal-treated-differently-by-sha256sum