Use mkdir on ubuntu

I was addicted to using mkdir during the program in ubuntu & C/C ++, so instead of a memorandum.

If it's windows, I can manage to use mkdir without worrying too much, but Option specification is required when using with ubuntu. If you make a mistake, you will create a directory that you do not have access to. It is kicked when creating a new file in that directory with the source immediately after.

Why can I create a directory without my own privileges? I don't know what it means (even though I haven't confirmed the specifications properly). Is it irrelevant when creating a directory because the authority is granted from the system side immediately after creating it? (Writing so far, I remembered ◯ Inter ☓ ◯ Inter ◯ RapiCa for a moment)

Well, what I wanted to make was to add the full path to the directory name specified by the relative path, A function that creates the directory and returns its full path. If the directory creation fails, it will return an empty string anyway (correspondence is miscellaneous).

okay. Anyway, I plan to operate it only when the directory structure is fixed in the system. (↑ A guy with this kind of thinking is a drag on team development)

std::string create_dir(std::string dir_name)
	char buf[1024] = "";
	if (NULL == getcwd(buf, sizeof(buf)))
		return "";
	std::string new_dir = buf + std::string("/") + dir_name;
	if (0 != mkdir(new_dir.c_str(), S_IRWXO | S_IRWXU | S_IRWXG))
		return "";
		return new_dir;

For example, here

	if (0 != mkdir(new_dir.c_str(), S_IRWXO))

If you do something like that, you will regret it later. Even though I made it myself, I do not have access authority (S_IRWXO grants full access authority to a third party) If you then try to create the file inside, you'll be confused.

Wouldn't it be nice if everyone had full access by default? If you are highly conscious, specify the option yourself. What's more, the mkdir page doesn't mention options. What do you mean Ya. At least put a link. ..

Recommended Posts

Use mkdir on ubuntu
Use Flutter on Ubuntu
Use cpplapack on ubuntu
How to use Bio-Formats on Ubuntu 20.04
Preparing to use electron-react-boilerplate on Ubuntu 20.4
tmux on Ubuntu
Use docker in proxy environment on ubuntu 20.04.1
Screen recording on Ubuntu 20.04
Web Bluetooth on Ubuntu20.04
Try DisplayLink on Ubuntu 20.04
Install pyqt5 on ubuntu
Install Ruby on Ubuntu 20.04
Setting JAVA_HOME on Ubuntu
Use bat on Centos.
Install Autoware on Ubuntu 18.04.5
Put JetBrains on Ubuntu
Apache2 on Ubuntu20.04 LTS
Use Corretto 11 on Heroku
ubuntu on wsl part 10
Install Homebrew on Ubuntu 20.04
Run tiscamera on Ubuntu 18.04
Build Zabbix on Ubuntu 20.04
Using Flutter on Ubuntu (Part 2)
Create SSL certificate on Ubuntu 18.04
Building WebGIS on Ubuntu20.04 LTS
Install OpenJDK7 (JAVA) on ubuntu 14.04
Put Ubuntu 20.04.1 on Raspberry Pi 4
Build VNC Server on Ubuntu 20.04
Install Cybozu Office 10 on Ubuntu 20.4
Extend swap area on Ubuntu 18.04
Install Docker on Ubuntu Server 20.04
Ubuntu on Windows Community Preview
Japanese input on Ubuntu20.04 Desktop
Use serial communication on Android
Oracle Java 8 on Docker Ubuntu
Install zabbix agent (5.0) on Ubuntu 18.04
Install MAV Proxy on Ubuntu 18.04
Use Swift Package on Playground
Install Arudino IDE on Ubuntu 20
Record video on ubuntu18.04 LTS
Introduced knowledge (wiki) on Ubuntu
Installing OpenMX on Ubuntu 18.04.5 LTS
Install Java on WSL Ubuntu 18.04
Ruby installation on WSL2 + Ubuntu 20.04
Install Ubuntu Desktop 20.10 on RaspberryPi4
Run chromium-mir-kiosk on Ubuntu Core
Install Arduino IDE on Ubuntu 20.04
Ubuntu on Windows build speed
Use devise on multiple models
Run java applet on ubuntu
Install raspi-config on Ubuntu 20.04 (LTS)
Use native code on Android
Install WordPress 5.5 on Ubuntu 20.04 LTS
Run Eclipse CDT on Ubuntu
Set up ansible-playbook on Ubuntu 20.04
Install PlantUML on Intellij on Ubuntu
Install Ubuntu Server 20.04 on Btrfs
Note: Install PostgreSQL 9.5 on Ubuntu 18.04
Use PG Backups on Heroku
I want to use screen sharing on the login screen on Ubuntu 18
Use the high-performance SQL development tool "A5: SQL Mk-2" on Ubuntu