Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 699467
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T03:23:23+00:00 2026-05-14T03:23:23+00:00

Apparently, NSFileManager is unable to delete files created by mkstemp() . Here’s some test

  • 0

Apparently, NSFileManager is unable to delete files created by mkstemp(). Here’s some test code to demonstrate this:

char pathCString[] = "/tmp/temp.XXXXXX";
int fileDescriptor = mkstemp(pathCString);
if (fileDescriptor == -1) {
    NSLog(@"mkstemp failed");
} else {
    close(fileDescriptor);
    NSURL *url = [NSURL URLWithString:[NSString stringWithCString:pathCString encoding:NSASCIIStringEncoding]];
    NSLog(@"URL: %@", url);
    NSError *error;
    if (![[NSFileManager defaultManager] removeItemAtURL:url error:&error]) {
        NSLog(@"could not delete file: %@", error);
    }
}

Here’s what I see in the log when I run the above code:

URL: /tmp/temp.A7DsLW
could not delete file: Error Domain=NSCocoaErrorDomain Code=4 UserInfo=0x1001108a0 "The file “temp.A7DsLW” doesn’t exist."

I’m running this on Snow Leopard. Any ideas on why the problem is occurring and/or how to work around it?

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T03:23:23+00:00Added an answer on May 14, 2026 at 3:23 am

    Don’t use -URLWithString:, use -fileURLWithPath: you didn’t make a valid file URL. Passing the path string directly to NSFileManager’s -removeItemAtPath: will of course be shorter.

    Also, for file paths, always make the path string with -stringWithUTF8String:.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Apparently, this call to window.open is not valid under Internet Explorer. The Javascript code
Apparently, this code gives me error at the last line cvCvtColor(), what is wrong?
Apparently using the URL is no good - why is this the case, and
Apparently we use the Scrum development methodology. Here's generally how it goes: Developers thrash
Apparently I can't move files on different volumes using Directory.Move. I have read that
Apparently some vendors (like Telerik) are working on versions of their controls that do
Apparently this is deprecated : cell.textColor = [UIColor whiteColor]; Does anyone know what the
Apparently, I am using params[:category] (from routing...) to categorize some articles within same table,
Apparently I don't understand something about binding ListBox controls to data. Here is a
Apparently this problem comes up fairly often, after reading Regular expression to detect semi-colon

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.