Reputation: 14906
This code for getting a temporary filename is returning an empty string. I'm trying to work out how it ever worked, since all doco I can find on mkstemp
says it needs a format of something like /tmp/prefixXXXXXX
, and here that's not being used.
function get_Temp_Name
return String
is
Temp_File_Name : String (1 .. 25) := (others => ' ');
C_Buffer : aliased Interfaces.C.Char_Array := Interfaces.C.To_C(Temp_File_Name, Append_Nul => True);
C_Ptr : constant Interfaces.C.Strings.Chars_Ptr := Interfaces.C.Strings.To_Chars_Ptr(C_Buffer'Unchecked_Access);
Result_Ptr : Interfaces.C.Strings.Chars_Ptr;
begin
Result_Ptr := C_Mkstemp(C_Ptr);
return Ada.Strings.Fixed.Trim(Interfaces.C.To_Ada(C_Buffer, True), Ada.Strings.Both);
EXCEPTION
when Error : others =>
-- redacted
raise;
end Get_Temp_Name;
Is this an old form of the call?
Would directory permissions effect the execution of C_Mkstemp()
?
EDIT: definition / import of C_Mkstemp
:
function C_Mkstemp( template : Interfaces.C.Strings.Chars_Ptr )
return Interfaces.C.Strings.Chars_Ptr;
pragma Import(C, C_Mkstemp, "mkstemp");
Upvotes: 1
Views: 111