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

  • SEARCH
  • Home
  • 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 984311
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T04:59:42+00:00 2026-05-16T04:59:42+00:00

My application generates loads of images and in order to save memory, I write

  • 0

My application generates loads of images and in order to save memory, I write these files to the temporary directory and read them when needed. I write two versions of the same image to the tmp folder one the thumbnail version at lower resolution and the other is full size. To make the file names unpredictable, I add a string hash at the end.

For instance I want to have two images one called “ThumbnailImage.fgl8bda” and the other “FullImage.fgl8bda”

This is the code I use:

NSString *fileName = @"Image.XXXXXXX";
NSString *thumbName = [@"Thumbnail" stringByAppendingFormat:@"%@", fileName];
NSString * thumbPath = [self writeToTempFile:thumbNailImage andName: thumbName];

NSString *fullName = [@"Full" stringByAppendingFormat:@"%@", fileName];
NSString *fullPath = [self writeToTempFile:fullImage andName: fullName];

However, the two files come out with different names, i.e. each time I use the fileName variable the hash is regenerated. For instance, my two images are called “ThumbnailImage.jhu078l” and “FullImage.ksi9ert”.

Any idea how I can use the same hash more than once?

  • 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-16T04:59:42+00:00Added an answer on May 16, 2026 at 4:59 am

    It is generally not safe to reuse a temporary file name suffix, because even if you can ensure A.ashkjd does not exist, there is a chance B.ashkjd is occupied.

    You could construct a folder and store the two images in it, e.g.

    char tmpl[] = "Image.XXXXXX";
    char* res = mkdtemp(tmpl);
    if (res != NULL) {
       NSString* dirName = [NSString stringWithUTF8String:res];
       NSString* thumbPath = [dirName stringByAppendingPathComponent:@"Thumbnail.png"];
       [thumbImage writeToFile:thumbPath atomically:YES];
       NSString* fullPath = [dirName stringByAppendingPathComponent:@"Full.png"];
       [fullImage writeToFile:fullPath atomically:YES];
    }
    

    (Note: you need to remove the folder manually.)

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

Sidebar

Related Questions

I have a application that generates a couple of different mails. These mails are
I have an application that generates xml files, and they might contain special characters.
I've got an application which generates SecretKeys, one per client. These need to be
I have a small C# ASP.NET web application which generates several PNG image files
I am developing an application that loads images and video into a Flash player
I'm working on an application that generates a set of bitmaps and then loads
My application generates binary data (compressed xml) and saves it to the Google App
My Java Swing application generates an HTML file, and I want to open it
I have a some of html strings that my application generates. Each html 'snippet'
I have an application that generates around 10000 printed pages per month. Each report

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.