MCPcopy Create free account
hub / github.com/Meituan-Dianping/SQLAdvisor / my_create

Function my_create

mysys/my_create.c:36–74  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

34
35
36File my_create(const char *FileName, int CreateFlags, int access_flags,
37 myf MyFlags)
38{
39 int fd, rc;
40 DBUG_ENTER("my_create");
41 DBUG_PRINT("my",("Name: '%s' CreateFlags: %d AccessFlags: %d MyFlags: %d",
42 FileName, CreateFlags, access_flags, MyFlags));
43#if defined(_WIN32)
44 fd= my_win_open(FileName, access_flags | O_CREAT);
45#else
46 fd= open((char *) FileName, access_flags | O_CREAT,
47 CreateFlags ? CreateFlags : my_umask);
48#endif
49
50 if ((MyFlags & MY_SYNC_DIR) && (fd >=0) &&
51 my_sync_dir_by_file(FileName, MyFlags))
52 {
53 my_close(fd, MyFlags);
54 fd= -1;
55 }
56
57 rc= my_register_filename(fd, FileName, FILE_BY_CREATE,
58 EE_CANTCREATEFILE, MyFlags);
59 /*
60 my_register_filename() may fail on some platforms even if the call to
61 *open() above succeeds. In this case, don't leave the stale file because
62 callers assume the file to not exist if my_create() fails, so they don't
63 do any cleanups.
64 */
65 if (unlikely(fd >= 0 && rc < 0))
66 {
67 int tmp= my_errno;
68 my_close(fd, MyFlags);
69 my_delete(FileName, MyFlags);
70 my_errno= tmp;
71 }
72
73 DBUG_RETURN(rc);
74} /* my_create */

Callers 4

create_temp_fileFunction · 0.85
my_copyFunction · 0.85
my_create_with_symlinkFunction · 0.85
inline_mysql_file_createFunction · 0.85

Calls 5

my_win_openFunction · 0.85
my_sync_dir_by_fileFunction · 0.85
my_closeFunction · 0.85
my_register_filenameFunction · 0.85
my_deleteFunction · 0.85

Tested by

no test coverage detected