MCPcopy Create free account
hub / github.com/cgsecurity/testdisk / create_pathname

Function create_pathname

src/ntfs_udl.c:774–807  ·  view source on GitHub ↗

* create_pathname - Create a path/file from some components * @dir: Directory in which to create the file * @dir2: Pathname to give the file (optional) * @name: Filename to give the file (optional) * @stream: Name of the stream (optional) * @buffer: Store the result here * @bufsize: Size of buffer * * Create a filename from various pieces. The output will be of the form:

Source from the content-addressed store, hash-verified

772 * Return: n Length of the allocated name
773 */
774static int create_pathname(const char *dir, const char *dir2, const char *name,
775 const char *stream, char *buffer, int bufsize)
776{
777 char *namel;
778 if (name==NULL)
779 name = UNKNOWN;
780 namel=gen_local_filename(name);
781 if(dir2)
782 {
783 char *dir2l=gen_local_filename(dir2);
784 if (stream)
785 {
786 char *streaml=gen_local_filename(stream);
787 snprintf(buffer, bufsize, "%s/%s/%s:%s", dir, dir2l, namel, streaml);
788 free(streaml);
789 }
790 else
791 snprintf(buffer, bufsize, "%s/%s/%s", dir, dir2l, namel);
792 free(dir2l);
793 }
794 else
795 {
796 if (stream)
797 {
798 char *streaml=gen_local_filename(stream);
799 snprintf(buffer, bufsize, "%s/%s:%s", dir, namel, streaml);
800 free(streaml);
801 }
802 else
803 snprintf(buffer, bufsize, "%s/%s", dir, namel);
804 }
805 free(namel);
806 return strlen(buffer);
807}
808
809/**
810 * open_file - Open a file to write to

Callers 1

undelete_fileFunction · 0.85

Calls 2

gen_local_filenameFunction · 0.85
snprintfFunction · 0.85

Tested by

no test coverage detected