Montag, 26. Oktober 2015

Entfernung der Attributen com.apple.ResourceFork, com.apple.FinderInfo, com.apple.quarantine. im Objektive-C


Mac Dateien beinhalten manchmal die Arttibuten wie
com.apple.ResourceFork, com.apple.FinderInfo, com.apple.quarantine.
Die auch als META Daten bezeichnet sind.

Wie soll man vorgehen, die Attribute von der Datei entfernt werden sollen?
Das war für mich die Aufgabe, weil sonst kann ich eine Datei in einem Programm nicht kopieren.  Nur sobald die Attribute entfernt sind, findet die Übertragung statt.

Also, eine Entfernung der Attributen im Objektive-C Sprache:

//Path Adresse
    const char* xattrURL = [subpath UTF8String]; //Path Adresse soll const sein
    //Welche von 3 Attribute existieren bereits? "-1" - keine, mehr als 0 - ist da
    ssize_t len  = getxattr(xattrURL, "com.apple.ResourceFork", NULL, 0, 0, 0);
    ssize_t len2 = getxattr(xattrURL, "com.apple.FinderInfo",   NULL, 0, 0, 0);
    ssize_t len3 = getxattr(xattrURL, "com.apple.quarantine",   NULL, 0, 0, 0);
    NSLog(@"getxattr com.apple.ResourceFork: %zd, com.apple.FinderInfo %zd, com.apple.quarantine %zd", len, len2, len3);
    //Attributs löschen
    int removeResult2 = removexattr(xattrURL, "com.apple.FinderInfo",   0);
    int removeResult  = removexattr(xattrURL, "com.apple.ResourceFork", 0);
    int removeResult3 = removexattr(xattrURL, "com.apple.quarantine",   0);
    //Wurden Attributs gelöscht? "-1" - nein, bzw. waren sie davor nicht da, mehr als 0 - nicht gelöscht
    NSLog(@"com.apple.ResourceFork: %zd, com.apple.FinderInfo: %zd, com.apple.quarantine %zd", removeResult, removeResult2, removeResult3);
    ssize_t len4 = getxattr(xattrURL, "com.apple.ResourceFork", NULL, 0, 0, 0);
    ssize_t len5 = getxattr(xattrURL, "com.apple.FinderInfo",   NULL, 0, 0, 0);
    ssize_t len6 = getxattr(xattrURL, "com.apple.quarantine",   NULL, 0, 0, 0);
    NSLog(@"com.apple.ResourceFork: %zd, com.apple.FinderInfo: %zd, com.apple.quarantine %zd", len4, len5, len6);

Keine Kommentare:

Kommentar veröffentlichen