Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

280
Views
Cómo convertir una ruta HFS clásica en una ruta POSIX

Estoy leyendo archivos antiguos que aún usan rutas de estilo HFS, como VolumeName:Folder:File .

Necesito convertirlos en rutas POSIX.

No me gusta hacer el reemplazo de cadenas ya que es un poco complicado, ni quiero invocar operaciones de AppleScript o Shell para esta tarea.

¿Hay una función de marco para lograr esto? La depreciación no es un problema.

Por cierto, aquí hay una solución para la operación inversa .

over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

La operación "inversa" de CFURLCopyFileSystemPath() es CFURLCreateWithFileSystemPath() . Del mismo modo que en las preguntas y respuestas a las que se hace referencia, ha creado el estilo de ruta a partir del valor de enumeración sin formato, ya que CFURLPathStyle.cfurlhfsPathStyle está obsoleto y no está disponible. Ejemplo:

 let hfsPath = "Macintosh HD:Applications:Xcode.app" if let url = CFURLCreateWithFileSystemPath(nil, hfsPath as CFString, CFURLPathStyle(rawValue: 1)!, true) as URL? { print(url.path) // /Applications/Xcode.app }
over 4 years ago · Santiago Trujillo Report

0

Una solución en Obj-C y Swift como categoría/extensión de NSString / String . El estilo kCFURLHFSPathStyle no disponible se elude de la misma manera que en la pregunta vinculada.

C objetivo

 @implementation NSString (POSIX_HFS) - (NSString *)POSIXPathFromHFSPath { NSString *posixPath = nil; CFURLRef fileURL = CFURLCreateWithFileSystemPath(kCFAllocatorDefault, (CFStringRef)self, 1, [self hasSuffix:@":"]); // kCFURLHFSPathStyle if (fileURL) { posixPath = [(__bridge NSURL*)fileURL path]; CFRelease(fileURL); } return posixPath; } @end

Rápido

 extension String { func posixPathFromHFSPath() -> String? { guard let fileURL = CFURLCreateWithFileSystemPath(kCFAllocatorDefault, self as CFString?, CFURLPathStyle(rawValue:1)!, self.hasSuffix(":")) else { return nil } return (fileURL as URL).path } }
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!