Add GetTempFileName
This commit is contained in:
		
							parent
							
								
									2537f3d413
								
							
						
					
					
						commit
						68e3ce2fe7
					
				| @ -146,6 +146,16 @@ TF_StringStream* TF_GetLocalTempDirectories() { | ||||
|   return list; | ||||
| } | ||||
| 
 | ||||
| void TF_GetTempFileName(const char* extension, std::string* name, | ||||
|                         TF_Status* status) { | ||||
|   *name = ::tensorflow::Env::Default()->GetTempFilename(extension); | ||||
|   if (*name.length() == 0) { | ||||
|     TF_SetStatus(status, TF_INTERNAL, "Can not create temp file name"); | ||||
|   } else { | ||||
|     TF_SetStatus(status, TF_OK, ""); | ||||
|   } | ||||
| } | ||||
| 
 | ||||
| TF_CAPI_EXPORT extern uint64_t TF_NowNanos(void) { | ||||
|   return ::tensorflow::Env::Default()->NowNanos(); | ||||
| } | ||||
|  | ||||
| @ -152,6 +152,12 @@ TF_CAPI_EXPORT extern TF_StringStream* TF_GetChildren(const char* filename, | ||||
| // The caller is responsible for freeing the list (see TF_StringStreamDone).
 | ||||
| TF_CAPI_EXPORT extern TF_StringStream* TF_GetLocalTempDirectories(void); | ||||
| 
 | ||||
| // Creates a temporary file name with an extension.
 | ||||
| // The caller is responsible for freeing the returned pointer.
 | ||||
| TF_CAPI_EXPORT extern void TF_GetTempFileName(const char* extension, | ||||
|                                               std::string* name, | ||||
|                                               TF_Status* status); | ||||
| 
 | ||||
| // Returns the number of nanoseconds since the Unix epoch.
 | ||||
| TF_CAPI_EXPORT extern uint64_t TF_NowNanos(void); | ||||
| 
 | ||||
|  | ||||
| @ -327,6 +327,8 @@ string GetTempFilename(const string& extension) { | ||||
|   } | ||||
|   LOG(FATAL) << "No temp directory found."; | ||||
| #endif | ||||
|   // Return an empty string to indicate that we can not create temp file name.
 | ||||
|   return ""; | ||||
| } | ||||
| 
 | ||||
| bool GetTestUndeclaredOutputsDir(string* dir) { | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user